hb
24th September 2007, 08:26
I am using a QThread to do some large-scale computation in a worker thread. If there is nothing to do, however, the worker thread is waiting in a wait condition, similar to how it is done in the Mandelbrot example. My thread class works well and has non-trivial logic (when to enter an event loop, exit it again, go to sleep in the wait condition etc), , so I would like to keep it that way.
Now I realized that I need cross-threads (queued) signal/slot connections for objects that live in the worker thread. Of course, the slots are not executed if the thread is currently in a wait condition.
My idea was now to add a function to the thread class that would execute all pending events, and then go to sleep again in the wait condition. That way, I could emit my signals, and then make sure to wake up the thread to execute the corresponding slots.
Unfortunately, although QThread have an event loop, there is no such thing as QThread::processEvents(). Is there any workaround to achieve what I want?
Now I realized that I need cross-threads (queued) signal/slot connections for objects that live in the worker thread. Of course, the slots are not executed if the thread is currently in a wait condition.
My idea was now to add a function to the thread class that would execute all pending events, and then go to sleep again in the wait condition. That way, I could emit my signals, and then make sure to wake up the thread to execute the corresponding slots.
Unfortunately, although QThread have an event loop, there is no such thing as QThread::processEvents(). Is there any workaround to achieve what I want?