QNetworkAccessManager *net_manager_ = new QNetworkAccessManager(this);
connect(net_manager_, SIGNAL(finished(QNetworkReply*)), receiver, SLOT(onNetworkFinished(QNetworkReply*)));
void LoginForm::onNetworkFinished(QNetworkReply * reply)
{
QString jsonData = reply->readAll();
QVariant variantCookies = reply->header(QNetworkRequest::SetCookieHeader);
QList<QNetworkCookie> cookies = qvariant_cast<QList<QNetworkCookie> >(variantCookies);
QNetworkCookie cookie=cookies.at(0);
QString DataAsString =cookie.toRawForm();//toRawForm方法是转换为QByteArray
qDebug() <<variantCookies <<variantCookies.toString() << " ---- " <<cookies.size()<<" "<<cookies.at(0)<<" "<<DataAsString;
}
网友评论