Results 1 to 4 of 4

Thread: Thread design advice needed

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Posts
    63
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Thread design advice needed

    My question is inside the run function below

    Qt Code:
    1. class TestObject : public QThread
    2. {
    3. Q_OBJECT
    4. private:
    5. QNetworkReply *m_reply;
    6. QUrl m_url;
    7.  
    8. public slots:
    9. void gotNetworkHeader()
    10. {
    11. // do something
    12. }
    13.  
    14. public:
    15. TestObject(QUrl url) : m_url(url)
    16. {
    17. }
    18.  
    19. void run()
    20. {
    21. QNetworkAccessManager nam;
    22. m_reply = nam.head(QNetworkRequest(m_url));
    23. connect(m_reply, SIGNAL(finished()), this, SLOT(gotNetworkHeader()));
    24.  
    25. //
    26. // what do I do here to stop the thread from
    27. // exiting until gotNetworkHeader has finished
    28. // execution?
    29. //
    30.  
    31. // I've tried exec(), but this seems to block QNetworkAccessManager
    32.  
    33. }
    34. };
    To copy to clipboard, switch view to plain text mode 
    Last edited by jonks; 22nd October 2009 at 04:47.

Similar Threads

  1. Advice needed regarding GUI and external thread cooperation
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 17th June 2009, 00:10
  2. Thread Design Question
    By craigdillabaugh in forum Qt Programming
    Replies: 4
    Last Post: 30th April 2009, 19:16
  3. QTableWidget Design & Thread Safety Question
    By bpetty in forum Qt Programming
    Replies: 4
    Last Post: 28th March 2008, 00:09
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. Replies: 10
    Last Post: 20th March 2007, 22:19

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.