0

I have created 2 *.ui using Qt Designer in my project, where one is the main screen and another one is a dialog widget. The dialog widget is called by one of the functions in main screen.

How can I connect the function in my main window to call the dialog widget?

e.g. If I click on [About > Author] in my main window's menu, I should be able to call the dialog widget.

Any help will be appreciated.

Thanks.

Wallace
  • 293
  • 1
  • 9
  • 18

1 Answers1

2

It depends on where you keep your dialog pointer. For example, you can create some signal on your main window and connect it with dialog show() slot(or exec() if you need it to be modal). Or if you keep your dialog pointer in the main windows then you can just use it with show/exec method directly.

As to About->Author menu: for that you should create QAction and add it to the menu. And QAction has triggered() signal which you can connect to exec/show slot of the dialog.

ixSci
  • 13,100
  • 5
  • 45
  • 79
  • Thanks for the reply. I'm confused as there's this "ui_xxx.h" generated from the .ui file, and also "xxx.h" and "xxx.cpp". Where should I declare my Dialog Widget show() slot? And where do I declare my Main Window signal() to connect to this Dialog Widget slot()? – Wallace Feb 17 '13 at 05:15
  • QDialog already has show/exec slots so you don't need to declare them. If you need to declare signal on Main WIndow you should do it on your MainWindow class which implements the ui(I don't know how it is done on your side, but I guess it is done via setupUi) and inheriting from your UI generated class. – ixSci Feb 17 '13 at 05:38