[Qt-interest] Signal chaining

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Mon Mar 29 14:38:46 CEST 2010


On Mon, Mar 29, 2010 at 5:43 PM, Andreas Pakulat <apaku at gmx.de> wrote:
> On 29.03.10 16:44:29, Mandeep Sandhu wrote:
>> On Mon, Mar 29, 2010 at 4:32 PM, Andre Somers <andre at familiesomers.nl> wrote:
>> > 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
>>
>> Hmmm....it's nice to connect signal to signal. Those re-emitting slots
>> looked bad! :)
>>
>> But for connecting signal of C to signal of A, I'll need to have C
>> visible in A (which I was trying to avoid, since C's something thats
>> for B's internal use! :)).
>
> No you don't. You only need A and C visible in B, which can then make the
> connection. Thats another nice thing about Qt's signal/slots you can

Right. But I didn't want to make A visible in B, since all these
sub-level classes are helper classes and really shouldn't bother about
who's calling.

Anyways, there's a signature change that happens when the signal goes
from B to A, so I'll have to have a "pitstop" slot in B where this
happens and emit it again!

Thanks,
-mandeep


> connect "arbitrary" objects with one another. The objects don't have to
> have any clue about each other.
>
> Andreas
>
> --
> You can do very well in speculation where land or anything to do with dirt
> is concerned.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>




More information about the Qt-interest-old mailing list