[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Newbie Developer to KDE
From:       Roberto Alsina <ralsina () conectiva ! com ! ar>
Date:       2001-04-22 18:17:19
[Download RAW message or body]

On Sun, 22 Apr 2001, Greg Hulands wrote:

> Hi Justin,
> The example you give, does not show an example of not knowing about each 
> other as you have to use the connect function which ties the two objects 
> together.

Ok, maybe this is more like you want.

Create an object with a signal of the same type of the signal you want,
let´s call him "connector".

Now, whenever you create an emitting object, "register" it by connecting
his signal to the signal of the connector (yes, you can connect signals to
signals ;-)

Now, whenever you create an object that has to receive the notification,
connect its slot to the connector´s signal.

That way, all classes need to know about the connector, but no class needs
to know about any other.

> 
> Greg.
> 
> On Sunday 22 April 2001 09:44, Justin wrote:
> > Hello,
> >
> > I fail to see how you cannot achieve this with signal/slots.  With Qt, the
> > objects to not have to know about each other at all.
> >
> > I'll use a classic pushbutton example:
> >
> > #include<qapplication.h>
> > #include<qpushbutton.h>
> >
> > main(int argc, char *argv[])
> > {
> > 	QApplication app(argc, argv);
> > 	QPushButton button("Press me to exit!", 0);
> >
> > 	// connect the signal to the slot
> > 	QObject::connect( &button, SIGNAL(clicked()), &app, SLOT(quit()) );
> >
> > 	app.setMainWidget(&button);
> > 	button.show();
> > 	app.exec();
> >
> > 	return 0;
> > }
> >
> > This creates a button that exits the application when clicked.  Neither
> > class (QApplication or QPushButton) knows about one another.
> >
> > -Justin
> >
> > On Sunday 22 April 2001 05:46, Greg Hulands wrote:
> > > Yes this is events within an application, if you have an object A which
> > > sends an event of say "I_HAVE_CHANGED" then any object should be able to
> > > register so that it gets notification of that event.
> > >
> > > The process for this is that the object registers itself to listen to the
> > > event and has an event handler for it. So when the event is posted to the
> > > notification center it then dispatches the event to all registered
> > > objects of that event. Both the poster and receiver do not have to know
> > > anthing about each other which decreases the coupling of objects in an
> > > application.
> > >
> > > Is this scenario possible with dcop, as i thought dcop was for
> > > interapplication communication?
> > >
> > >> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to
> > >> unsubscribe <<
>  
> >> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
> 

 ("\''/").__..-''"`-. .         Roberto Alsina
 `9_ 9  )   `-. (    ).`-._.`)  ralsina@conectiva.com.ar
 (_Y_.)' ._   ) `._`.  " -.-'   Director técnico
  _..`-'_..-_/ /-'_.'           Conectiva SA
(l)-'' ((i).' ((!.'             Buenos Aires - Argentina
                                KDE Developer (MFCH)
Futuaris nisi irrisus ridebis. (Carlton, De rerum comoedia)


>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic