Unsolved Emit Signal in QThread::run Not Working
qt27 last edited by
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()?
dheerendra Qt Champions 2022 last edited by
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/
kshegunov Moderators last edited by kshegunov
vladstelmahovsky last edited by
@qt27 just call QCoreApplication::processEvents() method after emitting or redesign your thread to one of the recommended ways