Qt 5.1 - QMessageBox Bug? Program Exits(0) if QMessageBox is called while QDialog is hidden
c++, qt
Solution
By default, a Qt application closes when the last window is closed (in your case, when you close the `QMessageBox`).
You can add this code to keep your application running:
qApp()->setQuitOnLastWindowClosed(false);
Problem
I seem to have discovered an annoying issue with Qt 5.1. Let's say for example you have a system tray icon (QSystemTrayIcon) and you hide your form (QDialog), so: ``` this->hide(); ``` Then, while the form is hidden, your app displays a message box: ``` QMessageBox::information(0, "Test", "Test"); ``` Once the user hits Ok to close the dialog, the program exits with exit code 0. So, it doesn't crash, but it politely exits. The only work around that I know off is to use the WIN32 API on Windows and the MessageBox function. This is not what I want to do. Is this a bug?