Results 1 to 18 of 18

Thread: Newbie threading question

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Newbie threading question

    This will not work! Because:

    1. Current situation
    Qt Code:
    1. connect(this, SIGNAL(needSleep(unsigned int)),
    2. mythread, SLOT(sleepFor(unsigned int)) , Qt::QueuedConnection);
    To copy to clipboard, switch view to plain text mode 
    This will post an event to the thread's event queue instead of calling sleepFor directly. Wrong again because sleepFor will be called from the thread's event queue and also affects the applications event dispatcher ( will freeze again ).
    I have attached a screenshot for the second case. As you can see the event dispatcher does not exit until sleepFor finishes.

    Solution:
    Do not sleep in the event handler.

    EDIT: Actually, the first case does not apply ( ). It is still QueuedConnections, since is another thread.

    Regards
    Attached Images Attached Images
    Last edited by marcel; 15th April 2007 at 09:13.

Similar Threads

  1. Replies: 1
    Last Post: 15th March 2007, 20:45
  2. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 14:38
  3. Tipical newbie question
    By Dark_Tower in forum Newbie
    Replies: 2
    Last Post: 24th March 2006, 06:24
  4. newbie question about qtextedit fields
    By otortos in forum Qt Programming
    Replies: 1
    Last Post: 23rd February 2006, 18:21

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.