qt-interest@trolltech.com
[Top] [All Lists]

Re: [Qt-interest] Simple question regarding the threads documentation

Subject: Re: [Qt-interest] Simple question regarding the threads documentation
From: Sean Harmer
Date: Thu, 18 Jun 2009 11:52:25 +0100
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

_______________________________________________
Qt-interest mailing list
Qt-interest@xxxxxxxxxxxxx
http://lists.trolltech.com/mailman/listinfo/qt-interest

<Prev in Thread] Current Thread [Next in Thread>