Results 1 to 9 of 9

Thread: Getting data from a QNetworkReply

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Getting data from a QNetworkReply

    Ok my question is really just how to read/get the return value if the function is ran by connect(),

    I only know how to get it using data = emit signal() but I can't emit finished() cause it's not mine.
    Que?

    From the trusty documentation we get the unequivocal:
    Signals are automatically generated by the moc and must not be implemented in the .cpp file. They can never have return types (i.e. use void).
    Frankly, you seem very confused. If you want to know that a network request has finished then you have no choice but to listen for the finished() signal from the QNetworkReply or QNetworkAccessManager. If you busy-wait on the request like you suggest then your application will not function: the request will not be sent until a Qt event loop is running again. You can use QEventLoop (connect reply->finished() to loop exit()) to block and maintain some responsiveness but a blocking design is really not the Qt way.

    When the request is successful then the data from the response can be read from the QNetworkReply. What you do with it then has nothing to do with the QNetworkReply signal/slot connection. You can choose to expose that data through an interface on your class, or send it on to another QObject(s) by emitting a signal of your own which can, as anda_skoa pointed out, happily carry a QByteArray payload.
    Last edited by ChrisW67; 3rd March 2014 at 06:41.

Similar Threads

  1. Replies: 0
    Last Post: 5th December 2011, 21:26
  2. Replies: 2
    Last Post: 14th August 2011, 06:47
  3. QNetworkReply: how to know when data is sent?
    By mentalmushroom in forum Qt Programming
    Replies: 17
    Last Post: 24th June 2011, 09:22
  4. Replies: 1
    Last Post: 8th March 2011, 07:27
  5. When to delete QNetworkReply?
    By QPlace in forum Qt Programming
    Replies: 5
    Last Post: 11th February 2009, 13: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
  •  
Qt is a trademark of The Qt Company.