Reputation: 7236
I am developing a Hospital Management System using Qt. It has options to create Patients, edit Patients and generate Bills. I used a QMainWindow and had three buttons in the Toolbar for each of these three options. Now when user selects one of these three buttons I want to load the form corresponding to that , foreg., Patient Creation Form or Patient Edit form and so on.. In QtDesigner for QMainWindow I was able to design one form based on the center widget. How to design multiple form and load them over center widget based on user action.
Upvotes: 0
Views: 931
Reputation: 18504
Add New -> Qt Designer Form Class
Set name of your class, mark "Create form"
, inherit QDialog
. Create your dialog using Qt Designer or do it by code and call it in MainWindow like this:
MyDialog dlg;
dlg.show();
To communicate between MainWindow
and your forms (for example send new data to your MainWindow
) you should use signals and slots.
If your forms should create and edit some data, you can do it modal. setModal
method
Upvotes: 2
Reputation: 2102
you should use QStackedWidget
The QStackedWidget class provides a stack of widgets where only one widget is visible at a time.
It's possible to manage stacked widgets by index or by their pointers.
Upvotes: 1