[Interest] QThreads: There's no one way to "do it right"! :)

Sze Howe Koh szehowe.koh at gmail.com
Wed Jan 23 11:48:12 CET 2013


On 23 January 2013 16:30, Konstantin Tokarev <annulen at yandex.ru> wrote:
> 23.01.2013, 12:29, "alexander golks" <alex at golks.de>:
>> but if you connect them queued, then they are executed in the thread, or not?
>
> Of course no (unless you are using moveToThread(this) which you shouldn't).

@Alexander: No.

To expand on what Konstantin said: QThread is NOT a thread; QThread is
a class that manages a thread.

Why is this distinction important? Well, it means that "QThread's
slot" = "The thread manager's slot" (NOT "The thread's slot"). If you
construct the QThread in the main thread, it will live in the main
thread. It doesn't live in the new thread. So when you make a queued
connection, the QThread's slot is invoked in the main thread, not the
new thread.


Regards,
Sze-Howe



More information about the Interest mailing list