[PyQt] QVariant and QList
cadevel at free.fr
Thu Apr 29 13:01:00 BST 2010
Phil Thompson a écrit :
> On Thu, 29 Apr 2010 13:17:05 +0200, cadevel <cadevel at free.fr> wrote:
>> Phil Thompson a écrit :
>>> On Thu, 29 Apr 2010 09:49:06 +0200, cadevel <cadevel at free.fr> wrote:
>>>> How can i convert a QVariant containing a QList<QNetworkCookie> to a
>>>> python list of QNetworkCookie.
>>> What's the context? What is creating the QVariant?
>> QVariant <qvariant.html> QNetworkReply::header
>> ( QNetworkRequest::KnownHeaders
>> <qnetworkrequest.html#KnownHeaders-enum> /header/ ) const
>> with hdr = QNetworkRequest::CookieHeader
>> ( corresponds to the HTTP Cookie header and contains aQList
>> <qlist.html><QNetworkCookie <qnetworkcookie.html>> representing the
>> cookies to be sent back to the server )
> I assume you have tried the obvious QVariant.toPyObject().
> Do you have a short test that I can run and will generate such a QVariant?
Yes i tried toPyObject() but it generates an exception
# -*- coding: utf-8 -*-
from PyQt4 import QtCore
from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest,
variant = reply.header(QNetworkRequest.SetCookieHeader)
nwm = QNetworkAccessManager()
reply = nwm.get(QNetworkRequest(QtCore.QUrl('http://www.google.com')))
More information about the PyQt