PDA

View Full Version : Can you send a signal to a thread?



Dumbledore
9th November 2007, 21:11
I don't know what is going on, I am positive I connected my signals properly and my thread won't respond the signal. Maybe it is not possible to send signals to threads? (Although I am able to send signals out of threads to my mainwindow no problem...)

jpn
9th November 2007, 21:31
Common pitfalls:

First of all, the QThread object itself lives in the thread it was created in. This is the thread where its slots get executed, not in thread which is being executed in QThread::run().
Secondly, QThread must enter to event loop with QThread::exec(). Running a busy loop in QThread::run() won't allow the thread to receive signals (which are delivered as events under the hood).

Hope this helps.