Qt-jambi-interest Archive, January 2008
close dialog together with application
Message 1 in thread
Hello!
I have an application that opens a modeless dialog at start up (a
logging window). After exiting the application the dialog window is
still open but I want it closed together with the application.
The parent is set to the QMainWindow.
Any suggestions welcome.
Thanks,
Michael
Message 2 in thread
Michael Brunneder wrote:
> Hello!
>
> I have an application that opens a modeless dialog at start up (a
> logging window). After exiting the application the dialog window is
> still open but I want it closed together with the application.
> The parent is set to the QMainWindow.
> Any suggestions welcome.
Hi Michael,
I suggest calling QApplication.quit(). That shuts down the event loop
and closes all windows. It also means that you can add custom
application shutdown logic after QApplication.exec();
best regards,
Gunnar
---
public class Dialog {
public static void main(String args[]) {
QApplication.initialize(args);
QMainWindow window = new QMainWindow() {
protected void closeEvent(QCloseEvent e) {
QApplication.quit();
}
};
QWidget dialog = new QWidget(window);
window.show();
dialog.show();
QApplication.exec();
// Custom application shutdown code...
}
}