[Qt-interest] Signal chaining

Andre Somers andre at familiesomers.nl
Mon Mar 29 13:02:01 CEST 2010


On 29-3-2010 12:47, Mandeep Sandhu wrote:
> Hi All,
>
> I have a requirement where I need to send out a notification (as a
> signal) to the user of my lib. The lib internally uses other helper
> classes for getting the notification. These classes are not exposed
> outside. All classes are QObjects.
>
> Eg: Class A (ext visible) --uses-->  Class B (internal) --uses-->Class
> C (internal)
>
> One way is to emit signal from C, connect it to B, which in turn would
> "re-emit"  it out to A, and so on (All signal-slot connections will be
> direct (not queued) since it operates in a single thread's context).
>
> Would it be lighter to use simple callbacks? (but then I would need
> the inner most class "C" to know about "A", since  finally A emits it
> out to a "user")
>
> I'm running this in an embedded box and was worried about the overhead
> of chaining these signals. If it's not much, I would prefer to use
> signals.
>    
How about just connecting the internal signals to the signals in the 
external API directly? You can connect signals to signals. There is no 
need for methods that do nothing else than re-emit a signal. Of course, 
that only works if the signatures are compatible.

André



More information about the Qt-interest-old mailing list