[Qt-interest] emitting signal from another class

Scott Aron Bloom Scott.Bloom at onshorecs.com
Thu Jul 15 20:12:50 CEST 2010



> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of John McClurkin
> Sent: Thursday, July 15, 2010 10:58 AM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] emitting signal from another class
> 
> Scott Aron Bloom wrote:
> >> John:
> >>
> >>> Ooops. Signals are protected. Only the class that defines the
> signal
> >>> can emit the signal. What you need is a public member function
that
> >>> emits the signal.
> >> There's an "escape clause", though, isn't there? By connect()ing
one
> >> signal to another, you can coerce a class to emit its signal in
> >> response to another class's compatible signal, right?
> >>
> >> As long as the connect() has access to the right objects from both
> >> classes, you're in business.
> >>
> >> Atlant
> >>
> >>
> > Yes.. you can absolutely connect one signal to another...
> >
> > Another method, that I have used (as does the Qt source) is create a
> > "emitSignal" method
> >
> > void MyClass::emitTheSignal( xxx, yyy )
> > {
> > 	emit theSignal( xxx, yyy );
> > }
> >
> However, what the OP seems to be doing is having a class call a method
> in a singleton class to modify data in the singleton class. Then, from
> within the modifying class, calling emit on the singleton class. It
> would be better for the singleton class's data modification method to
> emit the signal.
Im not sure what the OP's intent was... Since he was trying to call 
emit obj->signalName()

Its not clear to me...







More information about the Qt-interest-old mailing list