Dialogue box

Hi,

I’m creating a gui for my final year project at university. I want to be able to click on a button and for it to display a dialogue box. I’m not entirely sure how to do this. Can anyone offer any help/advice?

Thanks,

Lisa

Hi Lisa,

Please see the macro $ROOTSYS/tutorials/guitest.C that contains GUI examples and read the chapter ftp://root.cern.ch/root/doc/chapter23.pdf.

The simplest way is to use signals/slots communication mechanizm, i.e.

fTestButton = new TGTextButton(fStatusFrame, “&Open editor…”, 150);
fTestButton->Connect(“Clicked()”, “TestMainFrame”, this, “DoButton()”);

and in the DoButton() to create the dialog you want (instead as an Editor as it is done in the guitest.C)

Cheers, Ilka

Thanks for your help. I have read the chapter that you suggested, looked at the ROOT webpage and macros. However, I am still unsure of how to actually create the dialogue box, has anyone got an example that I could take a look at?

Thanks,

Lisa

Hi Lisa,
what’s type of dialog do you want?

Thanks. Regards. Valeriy

Hi Lisa,

The class TGTransientFrame defines a transient window that typically is used for dialogs windows. You need to use it for your dialog beside of the TGMainFrame class that defines the application window.

Best regards, Ilka

Hi Valeriy,

I want to create a simple dialogue box that contains labels and requires text entry.

Thanks,

Lisa

Dear Lisa,

Please find an example in he attached macro dialogExample.C. There are only two text buttons in the application window: Show Dialog and Exit. If you click on the Show Dialog button the dialog window pops up. You can enter a text that will be set as a label if you finish the input with the Enter key. OK button will close the dialog. Exit button will close the application.

Do not hesitate to ask questions if you have any.

Best regards, Ilka
dialogExample.C (6.18 KB)

hi Ilka

Thank you for all of your help and patience.

Lisa

Hi Ilka,

Can I link multiple classes in a LinkDef.h file? I have:

#ifdef CINT
#pragma link C++ class MainFrame;
#pragma link C++ class MyDialog;
#endif

but I’m still getting the error:

Error in TQObject::CheckConnectArgs: slot DoDialog() does not exist.

Thanks,

Lisa

Hi Lisa,

Yes, you can. Please check the class name given as an argument of the Connect method. If you still have a problem please see root.cern.ch/root/CintGenerator.html

Cheers, Ilka

Just a comment for the #pragma statements.

Do not use:
#pragma link C++ class MainFrame;
#pragma link C++ class MyDialog;

but
#pragma link C++ class MainFrame+;
#pragma link C++ class MyDialog+;

Rene