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
Events are processed by the main event loop, which lives in QApplication
or QCoreApplication
. So it does not make sense to send events to QObjects
in other threads (unless you create another event loop there which I am not sure is possible).
You can send events from other threads to your main thread, though. The myWorkerThread
in your example is owned by the main thread, because it is created there. Objects created by your worker thread in run()
and below are owned by this thread.
You also can send signals to slots in other thread, for example if you want to draw a widget (which must be done in the main thread) from your worker thread or similar.