I am not calling exec()
in my code, but the timer
and QUdpSocket
is working fine. Is exec()
used to wait for an event
to continue?
UPDATE: the timer
was working, because I had not called moveToThread(this)
on the QThread
, which meant the QThread
was actually still part of the main thread
. As for QUdpSocket
well I using the polling functions
. So it did not need to work with signals
.
TIP: if you need to do init
stuff, that requires an event loop
in your QThread
, you can delay
calling moveToThread
until you don't need the signals
anymore, that is practical when the program is loading. You also don't need to call it in the constructor (you could call it inside run()
for example), just copy the this QThread
pointer to a variable and make the call
later/elsewhere using the pointer.