Emit Signal in QThread::run Not Working
-
I have a thread that inherits from QThread and overwrite the run() function. Within that run function I do an emit. However, the receiver never gets it. When I do the exact same emit from a different function, then the receiver gets it.
Why doesn't it work from run()?
-
In the slot you have receiver object. Can you post sample code which you tried ? Is it in main thread or different thread ? Did you start event loop in thread which has receiver object ?
-
You need an event loop to process signals and you need to start it in the thread. You are doing threading wrong btw (not your fault, the documentation is embarrassingly terrible on this topic) see https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/
-
You need an event loop to process signals and you need to start it in the thread. You are doing threading wrong btw (not your fault, the documentation is embarrassingly terrible on this topic) see https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/
-
I have a thread that inherits from QThread and overwrite the run() function. Within that run function I do an emit. However, the receiver never gets it. When I do the exact same emit from a different function, then the receiver gets it.
Why doesn't it work from run()?
@qt27 just call QCoreApplication::processEvents() method after emitting or redesign your thread to one of the recommended ways