Results 1 to 2 of 2

Thread: Cannot get QNetworkCookie from QNetworkReply

  1. #1
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Cannot get QNetworkCookie from QNetworkReply

    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?
    It's not the goodbye that hurts,but the flashback that follow.

  2. #2
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot get QNetworkCookie from QNetworkReply

    I just find a post about this.
    This code should be this to work:
    Qt Code:
    1. QVariant v = reply->header(QNetworkRequest::SetCookieHeader);
    2. QList<QNetworkCookie> c = qvariant_cast<QList<QNetworkCookie> >(v);
    To copy to clipboard, switch view to plain text mode 
    It's not the goodbye that hurts,but the flashback that follow.

  3. The following 2 users say thank you to MorrisLiang for this useful post:

    Ishmael (22nd January 2011), queria (1st November 2010)

Similar Threads

  1. Subclassing QNetworkReply
    By piotr.dobrogost in forum Qt Programming
    Replies: 6
    Last Post: 19th December 2010, 08:42
  2. Replies: 2
    Last Post: 6th October 2010, 22:09
  3. Replies: 1
    Last Post: 12th April 2010, 13:14
  4. QNetworkReply::HostNotFoundError
    By timmu in forum Qt Programming
    Replies: 1
    Last Post: 25th August 2009, 10:58
  5. When to delete QNetworkReply?
    By QPlace in forum Qt Programming
    Replies: 5
    Last Post: 11th February 2009, 12:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.