PDA

View Full Version : Regarding communication b/w other thread and guithread to update the GUI



ashishsaryar
12th December 2012, 06:34
Hi All

I have problem to update the gui. I have made signal slot connection from one thread and my GUI thread. But its behaviour is not stable.
Some times gui hangs.

Can any one having any idea about how to fix the problem.

Currently I am working with qt 3.3.

Thanks
Ashish

anda_skoa
12th December 2012, 19:50
Wow, Qt 3.3!

In Qt3 all signal/slot connections are direct method invocations, so a slot in a GUI object must not be connected to signal in a worker thread (otherwise the worker thread will access GUI resources and that is not allowed).

What you do instead is create a custom QEvent subclass and use QApplication::postEvent to send that event to the GUI object. The event is delivered in the context of the main thread and can therefore access GUI resources.

Cheers,
_