Signal and slots

Hi,

I have an application in which I display ellipses in a Canvas.
The next feature that I would like to implement is to be able to click with the Left mouse on one of these ellipses and that this action pops up a canvas with some informations related to this ellipse.

To achieve this, I defined a class which is a public class of both TEllipse and TQObject classes.

class Pad:public TEllipse, public TQObject{
void PrintIt(){cout << “clicked” << endl;}
virtual void Clicked(Int_t id) { Emit(“Clicked(Int_t)”,id); }
};

then in the class where i created the different Pad objects, I link the signal and slots.
pad[channel]->Connect(“Clicked(Int_t)”,“Pad”,pad[channel],“PrintIt()”);

Unfortunately this seems not to work at all. Executing the binary output after compilation, I get:

Error in TQObject::CheckConnectArgs: signal TQObject::Clicked(int) does not exist

So my question is namely how to do to click on one TEllipse object and get it poping-up for a canvas for instance.
Thanks for your help.

Hi Nabil,

[quote=“Nabil”]Hi,

I have an application in which I display ellipses in a Canvas.
The next feature that I would like to implement is to be able to click with the Left mouse on one of these ellipses and that this action pops up a canvas with some informations related to this ellipse.
[/quote]

You can use
TCanvas::Picked
or
TCanvas::ProcessedEvent signals for that.
Check example at root.cern.ch/root/rqex/rqfiller.C

[quote]
To achieve this, I defined a class which is a public class of both TEllipse and TQObject classes.

class Pad:public TEllipse, public TQObject{
void PrintIt(){cout << “clicked” << endl;}
virtual void Clicked(Int_t id) { Emit(“Clicked(Int_t)”,id); }
};

then in the class where i created the different Pad objects, I link the signal and slots.
pad[channel]->Connect(“Clicked(Int_t)”,“Pad”,pad[channel],“PrintIt()”);

Unfortunately this seems not to work at all. Executing the binary output after compilation, I get:

Error in TQObject::CheckConnectArgs: signal TQObject::Clicked(int) does not exist

So my question is namely how to do to click on one TEllipse object and get it poping-up for a canvas for instance.
Thanks for your help.[/quote]

Slot should be known to CINT, so your class Pad
should have a dictionary.

HTH. Regards. Valeriy

hi,
as it has been suggested, I tried to start with the rqfiller.C and compile it as a standalone application (without using CINT).
I modified a bit the source code and in the source code, I commented :
RQ_OBJECT(“HFiller”)
and replaced it with:
class HFiller: public TQObject

I can excute it, but i do have this message that i do have this message
./rqfiller

Error in TQObject::CheckConnectArgs: slot ExecuteEvent(int,int,int,TObject*) does not exist
Error in TQObject::CheckConnectArgs: slot ExecuteEvent(int,int,int,TObject*) does not exist.

Is there something that I missed?
thanks!

Hi Nabil,
you need to create a class dictionary
Please, check $ROOTSYS/test/guiviewer.cxx
as one of examples of using signal-slots.

HTH. Regards. Valeriy

thanks!
I will carefully look at it.
cheers and thanks for the fast feedback.