PDA

View Full Version : QtConcurrent::run() and postEvent() method



dlib
10th April 2012, 21:29
Hi all, I read from Qt4.8 doc that

A QObject is said to have a thread affinity or, in other words, that it lives in a certain thread. This means that, at creation time, QObject saves a pointer to the current thread. This information becomes relevant when an event is posted with postEvent(). The event will be put in the corresponding thread's event loop. If the thread where the QObject lives doesn't have an event loop, the event will never be delivered.

I wonder if QtConcurrent::run() is using such postEvent() method in its multi-threading implementation.

What are possible interactions with a QTime object, making the implementation of QtConcurrent::run() calls work only where I put the commands Qtime::start() and Qtime::elapsed() around this piece of code? I suspect some interaction at Event level, but doc inspection brought no clear explanation till now.

Thanks and regards.