Results 1 to 3 of 3

Thread: QNetworkAccessManager in multiple threads

  1. #1
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default QNetworkAccessManager in multiple threads

    I am using QNetworkAccessManager instance as a static member of my class. When I use my class in another thread and try to call QNetworkAccessManager::post method I receive the following text in the output: "QObject: Cannot create children for a parent that is in a different thread." However everything seems to work fine. Yes, QNetworkAccessManager belongs to a different thread than the one it is used in, but is it really an error to call the post method from another thread, because I don't see any problems except this message?

    Qt Code:
    1. class MyClass: public QObject
    2. {
    3. //....
    4. static QNetworkAccessManger manager;
    5. //..
    6. }
    7.  
    8. // my class is then used in the thread
    9. void MyThread::run()
    10. {
    11. MyClass myclass;
    12. myclass.callPostMethod(); // here the warning is printed
    13. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Aug 2013
    Posts
    2
    Qt products
    Qt3
    Platforms
    MacOS X

    Default Re: QNetworkAccessManager in multiple threads

    I also think the finished(QNetworkReply *) signal should be removed from QNetworkAccessManager as it provides duplicate functionality to the finished() signal in QNetworkReply, but can also cause troubles, or at least uglier code, when you want to do multiple network requests based on previous network requests.

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

    Default Re: QNetworkAccessManager in multiple threads

    Why are you putting QNetworkAccessManagers in threads in the first place?

Similar Threads

  1. QNetworkAccessManager and multiple progress bars
    By bigjoeystud in forum Qt Programming
    Replies: 2
    Last Post: 2nd February 2011, 03:19
  2. FTP Program using multiple Threads
    By neveffects in forum Qt Programming
    Replies: 5
    Last Post: 3rd January 2011, 05:33
  3. Downloading multiple files using QNetworkAccessManager
    By aurorius in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2009, 10:51
  4. QNetworkAccessManager can't handle multiple cookies?
    By krippy2k in forum Qt Programming
    Replies: 5
    Last Post: 7th June 2009, 23:12
  5. Phonon on multiple threads
    By Savignon in forum Qt Programming
    Replies: 5
    Last Post: 6th March 2009, 22:17

Tags for this Thread

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.