Since I need to write a server client application where the clients run in their own thread I started reading about threading in Qt4.
In Qt4 as opposed to Qt3, QThread has its own event loop, that can be started with exec().
According to docs:
andint QThread::exec ()
Enters the event loop and waits until exit() is called or the main widget is destroyed, and returns the value that was set to exit() (which is 0 if exit() is called via quit()).
It is necessary to call this function to start event handling.
And here is what I don't understand so well:Having an event loop in a thread makes it possible to connect signals from other threads to slots in this threads, using a mechanism called queued connections.
Once exec() is called, run() is "halted" on that spot till quit() or exit() is called, which means, that I can't have a thread run an endless loop AND receive signals from other threads (i.e running an event loop) by means of processEvents() or similar.
The only solution I see is to create yet another object with my thread that will run my work loop, while my "parent" thread object runs the event loop...
But I tend to think I am just not getting something right here, which is why I am posting this :-)
Comments and explanations are more then welcome.
Thanks.
Bookmarks