PDA

View Full Version : How to make global signals for multi thread?



hind
4th July 2013, 11:22
I need a signal which can pass messages between threads, while when the message is sent the receiver may be executing a loop. For example, when a thread is doing a while loop I need it stop as soon as it knows.
The only way I can tell is making a variant accessable to the threads and protected by a mutex. It doesn't have to be complex, just a bool or int will do.
Well I don't think I can use signal/slot because in a while loop the slot won't be called.
I want to know if there is a more specialized class in Qt which can do this work.
Thanks in advance!

wysota
4th July 2013, 11:33
I want to know if there is a more specialized class in Qt which can do this work.
No, there is no such thing. Either you're using an event loop (in which case you can just use events to do what you want) or you're using a simple while loop in which case you're on your own.