Results 1 to 3 of 3

Thread: QNetworkAccessManager unknown error

  1. #1
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QNetworkAccessManager unknown error

    Hi all!

    I have almost become a nervous wreck already because of this thing:

    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <QtNetwork>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QCoreApplication a(argc, argv);
    7.  
    8. QNetworkAccessManager manager;
    9. QNetworkRequest request(QUrl("http://www.google.hu"));
    10.  
    11. QNetworkReply *reply = manager.get(request);
    12.  
    13. qDebug() << reply->errorString();
    14. return a.exec();
    15. }
    To copy to clipboard, switch view to plain text mode 

    It's that simple. And it doesn't work. It says: "Unknown error".

    Bad code? Bad proxy settings? What? Nokia's HTTP example works fine.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QNetworkAccessManager unknown error

    manager.get is asynchronous, it's likely that the request has only been posted and not even started by the time the reply->errorString() is executed, and thus, "Unknown error".

    Use signals and slots and you'll be told when the request has actually been executed, and THEN you can request the error code, if any.

  3. The following user says thank you to squidge for this useful post:

    lipk (20th March 2011)

  4. #3
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QNetworkAccessManager unknown error

    Oh. I thought if I can get any error message then there's an error...
    Finally I got it working. Thanks.

Similar Threads

  1. python qt4 unknown fatal error
    By izghitu in forum Newbie
    Replies: 0
    Last Post: 25th January 2011, 19:54
  2. QSslsocket and Unknown error
    By szarek in forum Qt Programming
    Replies: 21
    Last Post: 14th October 2010, 14:20
  3. unknown error reading svg file
    By RickF in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2010, 02:12
  4. QimageReader Unknown Error
    By bhaskar in forum Newbie
    Replies: 1
    Last Post: 2nd June 2010, 08:24
  5. Replies: 2
    Last Post: 15th February 2010, 06:42

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.