Accessing histo properties in custom GUI

Hello,

I am trying to create a simple GUI, with a couple of histograms created in the constructor. I’m trying to access some histo properties when selecting a specific a radiobutton, though I am currently getting a segfault. I am attching a MWE.

Any suggestion is very welcome !!

min.C (2.1 KB)

Hi,

Try with your modified script (MainWindow now inherits from TGMainFrame)
min.C (2.2 KB)

Cheers, Bertrand.

Thanks a lot Bertrand, indeed it works now very well.

May I ask what are the main differences, and which way is recommended (because I’ve seen examples both ways) between inheriting from TGMainFrame and having a private TGMainFrame member ? Why this affects ownership of the histograms in this case ?

Thanks again and best regards,
Sergio

Hi Sergio,

This doesn’t change the ownership, but the dictionary (signal/slots) generation. If you use ClassDef, then your class should inherit from TObject (TGMainFrame in this particular case).
And I would advise to always inherits from TGMainFrame if your class is a TGMainFrame (then it inherits also its signal/slots capability).

Cheers, Bertrand.

Got it, thanks a lot !

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.