PDA

View Full Version : Classic GUI and threading issue



stef13013
2nd August 2012, 11:41
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, things 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 !?

Is it possible to avoid this ?

Thanks.

mvuori
3rd August 2012, 13:32
Yes: Don't insert a very time consuming code to the UI thread... Do it like in the example: create an image, doing time-consuming processing, as QImage in the worker thread and just splash that into place in the UI thread -- which is very fast.

amleto
3rd August 2012, 15:59
I don't think we need to keep this one open...
http://www.qtcentre.org/threads/50341-Classic-GUI-and-threading-issue