Solved How can one have two or more active windows at the same time?
-
I have a small obstacle with my GUI application. I need to be able to use the pushbuttons of 2 separate windows at the same time.
That bottem bar is my toolbar. It is a separate window which I can open from the mainwindow.
Clicking on one of the toolbar's pushbuttons emits a signal to the mainwindow which opens one of the following windows; Help, maintenance, Details, SSP........ Database.
When one of the 'new' windows is open, I cannot use the buttons of the toolbar anymore. The idea is that if I open lets say the 'Help' window and I click on the 'SSP' button on the toolbar, the 'Help' window closes and the 'SSP' window opens.
Right now I have to manually close the 'new' window before I can use the Toolbar again. I have tried 2 ways of opening the windows but so far I have had no luck :/
Way 1:
help->setModal(true); help->setGeometry(0,0,1024,668); help->exec();
Way 2:
login = new Login(this); login->setGeometry(0,0,1024,668); login->exec();
Way 1 has as drawback that only the last-launched window is active and thus useable
Way 2 has more drawbacks. In case when I use it with the toolbar the signals become inactive so the pushbuttons don't do a thing. In case I use this way for any of the other windows, the toolbar becomes hidden as long as the other window is active. When I manually close the window the toolbar re-appears.
I tried every combination but no luck.
Which Magic Qt feature can make this obstacle go away?
-
@jsulm said in How can one have two or more active windows at the same time?:
@bask185 said in How can one have two or more active windows at the same time?:
help->setModal(true);
help->setGeometry(0,0,1024,668);
help->exec();You should not set modal to true and you should use show() instead of exec(). exec() is a blocking call - the caller will be blocked until the new window was closed. Modal windows/dialogs block other windows/dialogs until they are closed. See http://doc.qt.io/qt-5.9/qdialog.html
This works ;)
@SGaist said in How can one have two or more active windows at the same time?:
Hi,
What about using a QStackedWidget and switch between the widgets you want to show ?
I'll read it for usage in the feature. For now Jsulms simple solution suffices.
-
Hi,
What about using a QStackedWidget and switch between the widgets you want to show ?
-
@bask185 said in How can one have two or more active windows at the same time?:
help->setModal(true);
help->setGeometry(0,0,1024,668);
help->exec();You should not set modal to true and you should use show() instead of exec(). exec() is a blocking call - the caller will be blocked until the new window was closed. Modal windows/dialogs block other windows/dialogs until they are closed. See http://doc.qt.io/qt-5.9/qdialog.html
-
@jsulm said in How can one have two or more active windows at the same time?:
@bask185 said in How can one have two or more active windows at the same time?:
help->setModal(true);
help->setGeometry(0,0,1024,668);
help->exec();You should not set modal to true and you should use show() instead of exec(). exec() is a blocking call - the caller will be blocked until the new window was closed. Modal windows/dialogs block other windows/dialogs until they are closed. See http://doc.qt.io/qt-5.9/qdialog.html
This works ;)
@SGaist said in How can one have two or more active windows at the same time?:
Hi,
What about using a QStackedWidget and switch between the widgets you want to show ?
I'll read it for usage in the feature. For now Jsulms simple solution suffices.