PDA

View Full Version : Cannot get QNetworkCookie from QNetworkReply



MorrisLiang
25th May 2010, 16:50
void onFinished(QNetworkRequest * reply)
{
....
QVariant v = reply->header(QNetworkRequest::SetCookieHeader);
QList<QVariant> list = v.toList();
QList<QNetworkCookie> c = qvariant_cast<QList<QNetworkCookie> >(list);
....
}

I have a http detect tool,it tells me that the response contains 4 pieces of cookie.
But after calling v.toList(),I get a list whose length is 0.
So,what's wrong with it?

MorrisLiang
25th May 2010, 16:59
I just find a post about this.
This code should be this to work:


QVariant v = reply->header(QNetworkRequest::SetCookieHeader);
QList<QNetworkCookie> c = qvariant_cast<QList<QNetworkCookie> >(v);