I tried that on line 12 and 14 on the first post and "list" is empty.
I tried that on line 12 and 14 on the first post and "list" is empty.
Read again my last sentence and see what QVariant::toList() returns.
Makes cookies = QList<QNetworkCookie> and list = 0 itemsQt Code:
QList<QVariant> list = cookies.toList();To copy to clipboard, switch view to plain text mode
No, it makes it QList<QVariant> and not QList<QNetworkCookie> thus the size is 0 (because it is not a QList<QVariant>).
Aaaammm "No, it makes it QList<QVariant>............ (because it is not a QList<QVariant>)." ?
I suggest you rephrase this post because I have no idea what you mean. If it's that you don't see a difference between QVariant and QNetworkCookie then I suggest you click both links and read the docs to see the differences. You are trying to convert a QVariant holding a QList<QNetworkCookie> into QList<QVariant> which it is not thus you get an empty QList<QVariant>. It's like you wanted to convert a rectangle into a circle - you'd get an invalid circle because rectangles can't be converted to circles without actually knowing what a "rectangles" and "circles" are.
I didn't understand what he posted.... at firs he says that it's a QList<QVariant> and then in the brackets he says that it's not QList<QVariant>, but never mind that. I don't know how to convert it to a QList<QNetworkCookie> ? I guess not likeQt Code:
QList<QNetworkCookie> list = cookies.toList();To copy to clipboard, switch view to plain text mode![]()
No, at first "he" says the cast tries to make it QList<QVariant>.
Yes, so "he" says.and then in the brackets he says that it's not QList<QVariant>,
Actually you should mind because it is the most important part of the whole discussion.but never mind that.
I guess the compiler already told you it is not the right route...I don't know how to convert it to a QList<QNetworkCookie> ? I guess not likeQt Code:
QList<QNetworkCookie> list = cookies.toList();To copy to clipboard, switch view to plain text mode![]()
Try this:
Qt Code:
QList<QNetworkCookie> cookieList = qvariant_cast<QList<QNetworkCookie> >(cookies);To copy to clipboard, switch view to plain text mode
I don't know how to explain what happened...
My cookieList has 1 item: "d" wich is a QSharedDataPointer<QNetworkCookiePrivate> wich has another "d" wich is QNetworkCookiePrivate * with value 0x1 there is *d inside it wich is QNetworkCookiePrivate and insite that there is a QSharedData (commend,domain,expirationDate,httpOnly,name,path, secure,value) and they are all "not in scope"
You tried debugging a class your debugger has no support for. That's normal. Forget the debugger - after making the cast see the size of the list. If it is 0 then it's not a list but rather a QNetworkCookie object which would be strange. Try running this code (assuming "rep" is your QNetworkReply object):
Qt Code:
qDebug() << "Cookies set:" << var; QList<QNetworkCookie> cookies = qvariant_cast<QList<QNetworkCookie> >(var); foreach(QNetworkCookie c, cookies){ }To copy to clipboard, switch view to plain text mode
Again it's only one cookie. The JSESSIONID.
Great, finally... Now you should check if setting multiple set-cookie headers is a valid policy with HTTP/1.1. If so then probably reporting a bug to Qt Software is a good idea. If not, then you have to find a workaround for the faulty server for instance using QNetworkReply::rawHeaderList() and QNetworkCookie::parseCookies().
Bookmarks