Results 1 to 3 of 3

Thread: readyRead signal is not emitted

  1. #1
    Join Date
    Jun 2012
    Posts
    38
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: readyRead signal is not emitted

    Dear All,

    I have a small QT application that checks things from a web site. All was working fine some days ago, but all of the sudden my readyRead() SIGNAL is never emitted. That is my finished() signal is called before the readyRead().

    That is bad because I then get an empty HTML page back! ;-)

    My code does work with other web-sites, all I do is something very simple:

    Qt Code:
    1. #include <QtNetwork>
    2.  
    3. void myClass::startRequest(QUrl url,bool urlType)
    4. {
    5. QNetworkRequest request;
    6. request.setUrl(QUrl(url));
    7. request.setRawHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Firefox/31.0");
    8. reply = qnam.get(request);
    9. connect(reply, SIGNAL(readyRead()), this, SLOT(httpReadyRead()));
    10. connect(reply, SIGNAL(finished()), this, SLOT(httpFinished2()));
    11. connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(httpError(QNetworkReply::NetworkError)));
    12. }
    To copy to clipboard, switch view to plain text mode 

    so if I comment out the readyRead connect the application just hangs forever. If I uncomment it again the finished() signal is emitted shorty after, the httpReadyRead() is NEVER called.

    how can I troubleshoot this?

    thanks for any help you may offer...

    cheers!


    Added after 26 minutes:


    Okay, after investigating I realize that the there was a redirect that was not caught by my app.


    QVariant rUrl = httpReply->attribute(QNetworkRequest::RedirectionTargetAttri bute);
    qDebug() << rUrl;
    Last edited by gig-raf; 15th February 2016 at 16:21.

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: readyRead signal is not emitted

    What is the http status code when your finished signal is called? i.e. look at QNetworkReply::attribute with QNetworkRequest::HttpStatusCodeAttribute.

    Edit: didn't see your edit until after I posted... Tip is still valid though, when dealing with HTTP requests, always know the http status code...
    Last edited by jefftee; 16th February 2016 at 00:55.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  3. #3
    Join Date
    Jun 2012
    Posts
    38
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Thumbs up Re: readyRead signal is not emitted

    Thanks for your reply! Yes you are absolutely right.

Similar Threads

  1. Replies: 10
    Last Post: 3rd January 2015, 13:25
  2. Signal can't be emitted !
    By Vladimir_ in forum Newbie
    Replies: 32
    Last Post: 27th September 2014, 21:31
  3. Signal isn't emitted from socket
    By 8Observer8 in forum Newbie
    Replies: 3
    Last Post: 14th August 2013, 14:33
  4. signal emitted when I zoom
    By mastupristi in forum Qwt
    Replies: 1
    Last Post: 8th July 2009, 18:02
  5. Signal emitted more than once?
    By dbrmik in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2009, 13:44

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.