[Qt-interest] Simple question regarding the threads documentation

Sean Harmer sean.harmer at maps-technology.com
Thu Jun 18 12:52:25 CEST 2009


Hi,

On Thursday 18 Jun 2009 11:36:11 Patric wrote:
> I see what you mean... but I'm connecting one object of type MainWindow to
> another of type TestManager.
>
> testManager.moveToThread(MyThread::myThread);
>
> connect(this, SIGNAL(mainSignal()), &testManager, SLOT(onMainSignal()));
> connect(&testManager, SIGNAL(threadSignal()), this,
> SLOT(onThreadSignal()));
>
>
>
> And I'm just moving the testManager object to MyThread, and am connecting
> the MainWindow object to the TestManager object. And vice versa. And it's
> working.
That is because the connect statement will detect that you are making a 
connection that crosses thread boundaries and will use the QueuedConnect type 
automatically. This works by posting an event in the receiving objects event 
loop. That is why you must have an event loop running in a thread that you 
wish to receive signals from another thread.

The warning in the docs is related to event driven classes like QSocket 
classes not to classes in general.

Sean




More information about the Qt-interest-old mailing list