Difficulty making my own class generate signal

Hello,

I’m working with v3.10/1 gdk on win2K.
I have a simple class thats I want to generate signals that can be connected to TGProgressBar methods. The TGProgressBar::Connect() calls return kTRUE, but my TQObject::Emit() calls do nothing - TQObject::GetListOfClassSignals() returns 0 and TQObject::fListOfSignals is 0. What am I doing wrong here???

Here’s my class definition:#include <TQObject.h> class CGuiUpdate : public TQObject { public: static CGuiUpdate *GetInstance(); void SetProgressRange(Float_t lo,Float_t hi); // *SIGNAL* void SetProgressValue(Int_t value); // *SIGNAL* private: static CGuiUpdate *fInstance; CGuiUpdate(); }; and the implementation #include <TSystem.h> #include "CGuiUpdate.h" CGuiUpdate *CGuiUpdate::fInstance=0; //ClassImp(CGuiUpdate) //_____________________________________________________________________________ CGuiUpdate::CGuiUpdate() { fInstance = this; } //_____________________________________________________________________________ CGuiUpdate *CGuiUpdate::GetInstance() { if (fInstance) return fInstance; return new CGuiUpdate(); } //_____________________________________________________________________________ void CGuiUpdate::SetProgressRange(Float_t lo,Float_t hi) { Long_t args[2]; args[0] = (Long_t)lo; args[1] = (Long_t)hi; Emit("SetProgressRange(Float_t,Float_t)",args); } //_____________________________________________________________________________ void CGuiUpdate::SetProgressValue(Int_t value) { Float_t fVal = (Float_t)value; Emit("SetProssValue(Float_t)",fVal); gSystem->ProcessEvents(); }
Here’s the code that connects to the TGProgressBar:[code] TGCompositeFrame *part = fStatusBar->GetBarPart(1);
fProgress = new TGHProgressBar(part,300);
fProgress->SetBarColor(“red”);
fProgress->SetBackgroundColor(GetBackground());
part->AddFrame(fProgress,new TGLayoutHints(kLHintsExpandX,2,2,2,2));

CGuiUpdate *pUp = CGuiUpdate::GetInstance();
fProgress->Connect("SetRange(Float_t,Float_t)","CGuiUpdate",pUp,"SetProgressRange(Float_t,Float_t)");
fProgress->Connect("SetValue(Float_t)","CGuiUpdate",pUp,"SetProgressValue(Float_t)");

[/code]
I build the dictionary using makecint passing the above .h file and including the line “#pragma link C++ class CGuiUpdate;” in the linkdef.h file. Thanks…

Ed

Hi Ed, wait :wink:

  1. are you really going to connect signal to signal? i.e.

fProgress->Connect(“SetRange(Float_t,Float_t)”,“CGuiUpdate”,pUp,“SetProgressRange(Float_t,Float_t)”);
fProgress->Connect(“SetValue(Float_t)”,“CGuiUpdate”,pUp,“SetProgressValue(Float_t)”);

  1. to have “class signals” working you need include
    ClassImpQ(CGuiUpdate) in the implementation code

  2. change void SetProgressValue(Int_t value)
    to void SetProgressValue(Float_t value)

Does it help?

Regards. Valeriy

++
Happy Halloooween :imp:

Yikes! I got all mixed up here… I need to call

pUp->Connect(“SetProgressRange(Float_t,Float_t)”,“TGHProgressBar”,fProgress,“SetRange(Float_t,Float_t)”);

etc…

Thanks!

Ed

Hi,
Ok, after sorting out who is signalling who, I still have a problem: My parameters are not getting sent correctly: I “emit” with parameters 0 and 1.15747E7, but by the time the slot gets it, the parameters are both 0. Here’s a traceback

Examining the parameters in TQSlot::ExecuteMethod() I have[ul]
paramArr[0] = 0
paramArr[1] = 11574738
nparam = 2
[/ul]
Any idea what I failing to do? Thanks…
Ed