February 13, 2011

greatperson greatperson
Lab Rat
4 posts

Setting QList of cookies in QNetworkRequest in PySide

 

I’m trying to make a kind of web web browser using QtWebKit in PySide, and I have noticed a problem in QNetworkRequest’s setHeader() [pyside.org] method. I’m trying to set cookies, and the documentation says that I need to give two arguments to setHeader: QNetworkRequest.CookieHeader [pyside.org] constant and a QList < QNetworkCookie >. Yes, I have read it in the PySide’s docs, not in the Qt’s.

But PySide doesn’t have QList.

I’ve tried to give it a Python list:

  1. cookies = [ QNetworkCookie('lang','ru') ]
  2. request.setHeader(QNetworkRequest.CookieHeader, cookies)

But it doesn’t work:

QNetworkRequest::setHeader: QVariant of type QVariantList cannot be used with header Cookie

So what do I need to do to set cookies without QList?

___________________________
UPD. As a temporary solution, I currently use the setRawHeader() [pyside.org]:

  1. request.setRawHeader("Cookie", "lang=ru")

 Signature 

Sorry for bad English, C++ and Python. :-)

0 replies

 
  ‹‹ [PerlQt4] Building on Windows      PySide: Python for Qt version 1.0.0 release candidate 1 "The name doesn’t matter" released ››

You must log in to post a reply. Not a member yet? Register here!