In my Qt application, I have a main thread and a worker thread. The worker thread subclasses QThread
and processes events via customEvent
. Is this the correct way for the main thread to send events to be processed by the worker thread?
QThread* myWorkerThread = // ...
QApplication::instance()->postEvent (myWorkerThread, new MyWorkRequestEvent(/* ... */);
If I read the documentation correctly, it states that events are processed on the thread of the object that own the event recipient. Since QThread
was created by the main thread, it is owned by the main thread -- so would this event be processed by the main thread (which would be counter-intuitive, and in my case would be wrong)?