PDA

View Full Version : Minimize to tray - crash



mero
7th February 2012, 08:34
Hi,

I need help, I want to minimize program to tray, and everything is ok but when program is minimized and messagebox (or any dialog/popup) shows program is quiting with Exited normally (?!) Tested on qt 4.7 and 4.8.
So how and what I need to change in this code ? Or maybe there is better solution for minimizing program ? (I need example of course)



void MainWindow::changeEvent(QEvent *event)
{
QMainWindow::changeEvent(event);

if (event->type() == QEvent::WindowStateChange)
{
QWindowStateChangeEvent *e = (QWindowStateChangeEvent*)event;

if ((e->oldState() != Qt::WindowMinimized) && isMinimized())
{
if (Core::instance()->settings["minimize_to_tray"] == "on")
{
QTimer::singleShot(0, this, SLOT(hide()));
event->ignore();
}
}
}
}

Spitfire
8th February 2012, 15:52
Does the app crash before the message appears or after you close it?
If app crashes after closing the dialog my guess is that you have Qt::WA_QuitOnClose set to true.

If not, use debugger to see where and why it crashes and post relevant code or compilable example of the issue.