[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] QVariant  and QList
From:       cadevel <cadevel () free ! fr>
Date:       2010-04-29 12:01:00
Message-ID: 4BD974FC.20807 () free ! fr
[Download RAW message or body]

Phil Thompson a écrit :
> On Thu, 29 Apr 2010 13:17:05 +0200, cadevel <cadevel@free.fr> wrote:
>   
>> Phil Thompson a écrit :
>>     
>>> On Thu, 29 Apr 2010 09:49:06 +0200, cadevel <cadevel@free.fr> wrote:
>>>   
>>>       
>>>> Hello,
>>>>
>>>> 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?
>>>
>>> Phil
>>>   
>>>       
>> 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 )
>>
>> Christophe
>>     
>
> 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?
>
> Phil
>   

Yes i tried  toPyObject() but it generates an exception


# -*- coding: utf-8 -*-
from PyQt4 import  QtCore
from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest, 
QNetworkCookieJar
import sys

app=QtCore.QCoreApplication(sys.argv)


def on_finish():
    variant = reply.header(QNetworkRequest.SetCookieHeader)
    print variant
   
    app.quit()

nwm = QNetworkAccessManager()
reply = nwm.get(QNetworkRequest(QtCore.QUrl('http://www.google.com')))
app.connect(reply,QtCore.SIGNAL('finished()'), on_finish)

app.exec_()

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic