This will not work! Because:
1. Current situation
connect(this, SIGNAL(needSleep(unsigned int)),
mythread, SLOT(sleepFor(unsigned int)) , Qt::QueuedConnection);
connect(this, SIGNAL(needSleep(unsigned int)),
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
Bookmarks