[Qt-interest] QThread event loop running in main thread?
Thiago Macieira
thiago at kde.org
Mon Dec 27 15:05:31 CET 2010
On Monday, 27 de December de 2010 04:05:02 lbutler3 at comcast.net wrote:
> I seem to be having trouble with a QThread and signals/slots.
When I read the first sentence, I thought "he's using slots in a class derived
from QThread". So reading a bit below, we see:
> In my main window constructor I do:
>
> connect(this, SIGNAL(tweakThread()), &myThread, SLOT(tweak()),
> Qt::QueuedConnection);
Simply don't do that. DO NOT put slots in a class derived from QThread and
you'll save yourself a lot of headaches. You can add signals, but you
shouldn't.
Instead, create a new QObject with the signals and slots and make sure it's
moved to or created in the other thread.
Think of QThread as "the resource managing a thread", not the work to be done.
So "tweak" means tweaking the thread, whatever that should mean (as in "kill
the thread", "start the thread", "set the thread's priority").
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Senior Product Manager - Nokia, Qt Development Frameworks
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101227/bb1a18e1/attachment.bin
More information about the Qt-interest-old
mailing list