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?
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With