Results 1 to 8 of 8

Thread: QNetworkAccessManager doesn't call finished signal

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QNetworkAccessManager doesn't call finished signal

    UserApi is derived from AppApi, it is an instance of AppApi, just like in Python.

    So just call the implementation of the base class
    Qt Code:
    1. QString UserApi::sendMessage()
    2. {
    3. makeRequest(); // method of base class AppApi.
    4.  
    5. // return missing here. this is not a void method
    6. }
    To copy to clipboard, switch view to plain text mode 

    Also make sure you connect the manager's finished() signal only once, e.g. right after you create the manager.

    Cheers,
    _

  2. The following user says thank you to anda_skoa for this useful post:

    Swiftie (14th November 2014)

  3. #2
    Join Date
    Nov 2014
    Posts
    8
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QNetworkAccessManager doesn't call finished signal

    Thanks, i figured out.

    And the last question, it's how to properly return the response?
    I know how to "return" response in synchronous mode (using QEventLoop), but i need to implement returning response from async requests.
    Here the "example"
    Qt Code:
    1. UserApi *c = new UserApi;
    2. QJsonDocument j = QJsonDocument::fromJson(c->sendMessage(..parameters here..)); // c->sendMessage needs to return response from GET request
    To copy to clipboard, switch view to plain text mode 

    Best regards
    Last edited by Swiftie; 14th November 2014 at 15:59.

  4. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QNetworkAccessManager doesn't call finished signal

    You get the data in replyFinished() from the QNetworkReply object.

    Then you send it in a signal of your class if you want to handle it outside that object or call a virtual method that you implement in UserApi.

    Returning is inherently synchronous.

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    Swiftie (14th November 2014)

Similar Threads

  1. QNetworkAccessManager no finished() signal emitted
    By realperson in forum Qt Programming
    Replies: 4
    Last Post: 18th January 2018, 08:42
  2. Replies: 7
    Last Post: 7th August 2014, 06:43
  3. QFutureWatcher doesn't get finished signal
    By Mobility in forum Newbie
    Replies: 3
    Last Post: 20th September 2012, 09:25
  4. QNetworkAccessManager does not signal finished
    By lukas.zachy in forum Newbie
    Replies: 5
    Last Post: 26th January 2011, 09:05
  5. QUrlOperator doesn't emit finished signal
    By hayati in forum Qt Programming
    Replies: 16
    Last Post: 26th March 2007, 20:25

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.