PDA

View Full Version : Classic GUI and threading issue



stef13013
2nd August 2012, 12:43
Hi,

As I can read, to do the right thing with QT and GUI threading, we have to :
1. Create a new thread (I already have my MainWindow)
2. Compute inside this thread all the "heavy stuff"
3. Then sending a signal to main GUI thread (MainWindow) to do the all rendering/widget update.

Right, but I still don't understand how, in this same main thread, my main window will not freeze If I do important graphics updates

To give you an example :
In the Mandelbrot Qt sample, in the rendering function (updatePixMap()), if I insert a very time consuming code, all the main window still frozen !?
(eg I cannot move my window !?)

Is it possible to avoid this ?

Thanks.

amleto
2nd August 2012, 14:40
do expensive operations outside of the main thread... It's that simple.

stef13013
2nd August 2012, 15:27
Not a bad idea, indeed ;)

I wish I could get it just like Delphi does with its thread "Synchronize" method (VCL isn't thread-safe too)

Thanks anyway.

amleto
2nd August 2012, 15:37
c++11 has simple threads and QThread is pretty simple to use as well.

wysota
3rd August 2012, 18:43
This is also an almost mandatory lecture with these kinds of questions: Keeping the GUI Responsive.