Created a QThread in main() i.e Main thread. Moved a worker class to the new thread. The thread executes the \'StartThread\' method of worker class.
Worker Thread:>
You declared and initialized count
inside the while
loop. Move it outside and it will stop reinitializing to zero every iteration, and thus quit on time. I'm unclear why you've declared it static
, as well.
Note
If you intend to use queued signals and handle events, make sure you periodically call processEvents
on the thread's event dispatcher inside your while
loop:
if (thread()->eventDispatcher()->hasPendingEvents()
thread()->eventDispatcher()->processEvents();