View Full Version : How to close two main windows at a time
soumya
2nd February 2010, 10:09
Hi All,
I have two forms open i need to close both the forms together how this can be done any suggestions :)
aamer4yu
2nd February 2010, 10:18
Can you call QWidget::close :rolleyes:
soumya
2nd February 2010, 10:21
if i do that only one form will get closed and the other will be open i need to close both the forms together
navi1084
2nd February 2010, 10:43
Make 2nd one parent as first form and launch 2nd form as non-modal. Set the single closing slot where you are closing the parent form.
Else you can use QPrecess.
soumya
2nd February 2010, 10:48
I am closing the form using keypress event if i press escape key from keyboard one of my form will be closed but i need to close both the forms together.
navi1084
2nd February 2010, 11:12
use installEventFilter() from parent class and in eventFilter() check for the Keypressed event and ESCAPE Character. depending on that close everything
aamer4yu
2nd February 2010, 12:20
Are your forms custom widgets ?
If yes, you can override closeEvent of your widget and call qApp->quit().
spud
4th February 2010, 16:12
Or yet another suggestion:
QWidget *a, *b;
...
a->setAttribute(Qt::WA_DeleteOnClose);
b->setAttribute(Qt::WA_DeleteOnClose);
connect(a, SIGNAL(destroyed()), b, SLOT(deleteLater()));
connect(b, SIGNAL(destroyed()), a, SLOT(deleteLater()));
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.