I wrote this to prevent the user from closing the main dialog and leaving other windows open:
Code:
{ qApp->closeAllWindows(); } }
But when I click yes nothing happens and the program is blocked.
What I do wrong?
Printable View
I wrote this to prevent the user from closing the main dialog and leaving other windows open:
Code:
{ qApp->closeAllWindows(); } }
But when I click yes nothing happens and the program is blocked.
What I do wrong?
I have no means for a quick test at this moment, but try accepting the event.
Code:
{ qApp->closeAllWindows(); e->accept(); } }
Thank you. but whether I accept or ignore the event, still don't work.
I tried to call qApp->quit() instead of qApp->closeAllWindows(), it seems to work, but the destructor of the other windows opened are not called.
I open this other dialogs like this:
Code:
DlgTabla *t = new DlgTabla(); t->show();
A possible solution could be: construct the dialog with parent the main dialog:
The destructor is called, however all windows I show shares the same element of the main dialog in the task bar.Code:
DlgTabla *t = new DlgTabla(this); t->show();
There another way to close all windows and to call their destructors?
Or as alternative solution, show this other dialogs without sharing the same element in the task bar?
Thanks
I think the problem comes from the difference between closeEvent end close methods.
When ever a widget is attempted to be closed, QT calls closeEvent. And if you call another acrion causing close it will recursively call itself
So you SHOULD NOT call qApp->closeAllWindows in close event. just accept the event.
And if you want your app closed whenever your widget is closed, write the aboce closing code to close method.
Happy QTing
If your widgets are properly parented, I dont see need to even handle closeEvent. From what you posted it seems you want to call the destructor of custom widgets before the application or main window closes.Quote:
The destructor is called, however all windows I show shares the same element of the main dialog in the task bar.
There another way to close all windows and to call their destructors?
Or as alternative solution, show this other dialogs without sharing the same element in the task bar?
Am I right in understanding your requirement ?