[Qt-interest] emitting signal from another class

Sajjad dosto.walla at gmail.com
Thu Jul 15 20:52:17 CEST 2010


On Thu, Jul 15, 2010 at 8:12 PM, Scott Aron Bloom <Scott.Bloom at onshorecs.com
> wrote:

>
>
> > -----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...
>

Hello forum,

Thanks for the feedback. This is how i solved the issue.

I have 2 different gl widget class and a singleton shared class . The
glwidget class can access and update the data members of the singleton
class. When ever the data changes(data of singleton class object) in any of
the widgets class i  emit a signal belonging to a gl widgets class. This
signal is connected to the signal of the singleton class object.  And the
last signal is connected to a slot in the main window.


Any other better way to accomplish that ?


Regards
Sajjad

>
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100715/05e25c6f/attachment.html 


More information about the Qt-interest-old mailing list