dobedidoo
9th December 2009, 13:08
In my application I use a QSystemTray which enables me to hide ("minimize to tray") my main window, without closing it (the system tray icon is available for action).
Now I've noticed that if I use an action from the system tray icon's context menu to display a regular QMessageBox (eg. a standard information box with only an 'OK' button) when the main window is hidden (that is, I've called hide() from my main window), then my application crashes when I click the 'OK' button in the QMessageBox.
If the main window is not hidden, then all works fine.
Any ideas how I should prevent this crash?
I'm using Qt 4.4.3.
------------
Additional comment:
The following code causes a crash:
void MainWindow::trayIconMessageClicked()
{
QMessageBox box(QMessageBox::Information, "MyApp", "The message...", QMessageBox::Ok);
box.setWindowIcon(box.iconPixmap());
box.exec();
}
while the following apparently does not cause a crash:
void MainWindow::trayIconMessageClicked()
{
QMessageBox box(QMessageBox::Information, "MyApp", "The message...", QMessageBox::Ok);
box.setWindowIcon(box.iconPixmap());
box.exec();
show();
hide();
}
The show() and hide() act on the main window.
Now I've noticed that if I use an action from the system tray icon's context menu to display a regular QMessageBox (eg. a standard information box with only an 'OK' button) when the main window is hidden (that is, I've called hide() from my main window), then my application crashes when I click the 'OK' button in the QMessageBox.
If the main window is not hidden, then all works fine.
Any ideas how I should prevent this crash?
I'm using Qt 4.4.3.
------------
Additional comment:
The following code causes a crash:
void MainWindow::trayIconMessageClicked()
{
QMessageBox box(QMessageBox::Information, "MyApp", "The message...", QMessageBox::Ok);
box.setWindowIcon(box.iconPixmap());
box.exec();
}
while the following apparently does not cause a crash:
void MainWindow::trayIconMessageClicked()
{
QMessageBox box(QMessageBox::Information, "MyApp", "The message...", QMessageBox::Ok);
box.setWindowIcon(box.iconPixmap());
box.exec();
show();
hide();
}
The show() and hide() act on the main window.