[Qt-interest] Using One Signal and Multiple Slots

Andre Somers andre at familiesomers.nl
Fri Jan 29 11:03:04 CET 2010


Felix Werkmeister wrote:
> Hey,
>
> I implemented a thread with a signal that ist received by multiple other threads. Ist there an opportunity to let only some of the slots receive the signal? 
>   
No. Why did you connect them to the signal in the first place, if you 
don't want them to receive the signals?

But you could use several other options:
* use multiple signals for the different kinds of signals it seems you have
* add a parameter to the signal that helps listeners decide if they 
should act or not
* don't use signals, but use a callback or something like that
* have listeners register themselves and the slot they are listening 
with, and call an QMetaObject::invokeMethod on them using a 
Qt::QueuedConnection at the time you find appropriate
* ....

André





More information about the Qt-interest-old mailing list