Re: communication between different parts of application via signals



On Sunday 25 June 2006 18:13, Joe Van Dyk wrote:
> On 6/25/06, Joe Van Dyk <joevandyk gmail com> wrote:
> > Hi,
> >
> > Say a user clicks a checkbox in a menu that affects three other parts
> > of the application.  Would a signal be the best way to communicate
> > that change to the rest of the application?  How would that work?
> > Would I create a custom signal or slot?  How would the other parts of
> > the application listen to that signal?  Would I create the slot and
> > then pass that slot to the other parts of the application (i.e. in a
> > constructor)?
> >
> > Sorry for the basic questions, but signals and slots and functors are
> > still confusing to me.
> >
> > I'm also a gigantic fan of unit testing -- are signals unit testable?
>
> Historically, I've hooked up a function to the clicked event of the
> check box.  And that function calls member functions of the different
> objects in the application.  So, signals aren't used for
> communication.  But something about that seems smelly.

I do not really understand what you are saying.  sigc slots are just 
callbacks, executed at the point the signal is invoked.  Nothing "listens" to 
them; they just execute when called, like any other function pointer or 
functor or callback.

If the callback function calls other member functions it does so because you 
have coded the callback function to call the member functions.

Chris




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]