Creating exit button for a window
Solved
General and Desktop
-
wrote on 30 Aug 2017, 22:49 last edited by
Hello.
I created two windows. One shown, the other hidden.
A button on window 1 to show window 2.I'd like to make a "hide" button on window 2 for window 2.
I connected the "hide" button like this:
QObject::connect(closeBtn, SIGNAL(clicked()), qApp, SLOT(quit()));
It quits totally the app, but I want window 1 to stay open.
Isn't there something similar to close a single window?
Then I tried using win2.hide(); within a slot but it says "'win2' was not declared in this scope", even all .h files included.
Can anybody point me in the right direction?
-
wrote on 30 Aug 2017, 22:51 last edited by Shodan
Found it:
QObject::connect(exitBtn, SIGNAL(clicked()), this, SLOT(exitSlot())); } void window2::exitSlot() { window2::close(); }
-
Found it:
QObject::connect(exitBtn, SIGNAL(clicked()), this, SLOT(exitSlot())); } void window2::exitSlot() { window2::close(); }
@Shodan close() is a slot, so you can connect it directly without creating one more slot :-)
-
wrote on 3 Sept 2017, 15:37 last edited by
Thank you for the tip ;-)
1/4