View Full Version : Signals and Slots Across Threads

26th October 2007, 12:09

I'm developing an application which requires an object (lets call this object A) which will lay dorment until one of it's methods are called. This object should then execute the method within it's thread, not in the thread of the calling object.

My understanding is that this is possible by using queued signal connections but I would just like some clarification that I understand exactly how this will happen...

As I understand it, by implementing the methods as slots the other objects will be able to emit signals which will not execute the slot directly, instead the slot will be executed by object A's thread as soon as control is passed back to that thread. So... Does this mean that I could have the following in the A::run() method and still have the other methods executed by this thread when they are called via signals?

void A::run()
forever {

I assume that this will keep the thread alive and just use it to execute any slots called.

26th October 2007, 12:16
Please read DevDays2007-Threading.pdf (http://chaos.troll.no/~ahanssen/devdays2007/DevDays2007-Threading.pdf) starting from page 33. The QThread object itself lives in the thread it was created in, not in the thread which is executed in QThread::run().