Re: connecting signals & slots

From: Roger Mason <rmason_at_esd.mun.ca>
Date: Thu, 25 Jan 2007 17:50:10 -0330


Hi Valeri,

"Fine, Valeri" <fine_at_bnl.gov> writes:

> That has a few states like "pressed" "clicked" etc, all of those can be
> reported via Signal / Slot mechanism.

It is the "Clicked" state for which I need a response.

> I would like to call your attention the only thing *you* want to know
> from the button object is how the user has interacted with this button.

> The user can do only TWO things with the GUI component like button.
> He/she either press it or release it. That's all and this *is* signaled.
> It is up to your code how to respond. At this point your code can *pull*
> all information it needs. There is no need to pass all parameters
> through the signal / slot.

OK, that parameter passing is what I have been trying to do.

> The only thing you should pass via this
> channel is the flag that is to notify you about the user intention and
> whether the information is ready to be fetched.

So, I need to define a (global?) flag and, when (in this case) the starting parameters for my fit are entered, set it to "True" then test for "True" in the slot?

> Yes, the code should "know" where the information should be
> "phishing". Have you problem with the "phishing"?

Yes.

> Do you want to
> pass the object pointer?

Well, I need some way for the TF1 and the TGraph to which it is to be fitted to be dispatched to the slot (I think).

> You can send such pointer from the signal
> to the slot too. The later is simple and it should be sufficient.
>

Well, that is what have been trying to do:

class MyMainFrame {
...
public:
  void Fit(TGraph*, TF1*);
...
}

MyMainFrame::MyMainFrame(const TGWindow *p,UInt_t w,UInt_t h) { ...

   fit = new TGTextButton(fHframe2, "&Fit");    fit->Connect("Clicked()","MyMainFrame",this,"Fit(TGraph&, TF1&)");    fHframe2->AddFrame(fit, fLbutton);
...
}

void MyMainFrame::Fit(TGraph *graph, TF1 *thefit){   TF1 all = *thefit;
  graph->Fit("all");
}

When I compile, with ACLiC, compilation works but this error results:

Error in <TQObject::CheckConnectArgs>: slot MyMainFrame::Fit(TGraph&,TF1&) does not exist

I assume this is because the signature for Fit() does'nt correspond to that in the Connect() method. The present bodge is just one of several I have tried.

Thanks for your help.

Roger Received on Thu Jan 25 2007 - 22:20:29 CET

This archive was generated by hypermail 2.2.0 : Thu Jan 25 2007 - 23:50:00 CET