PDA

View Full Version : QSystemTrayIcon closed " unexpectedly"



tzioboro
9th December 2006, 19:45
Hello
I have encounter following issue.
I have an instance of DaemonTray that is subclass of QSystemTrayIcon
executing following code close whole program ... (Task bar icon disappears)


DaemonTray::config()
{
ConfigDialog dialog;
dialog.exec()
}

When I close the dialog with close() or reject() or clicking on X button on the dialog .. the whole application is closed.
I find out that reason is in QApplication::quitOnLastWindowClosed() which is default set to true. But the above behaviour occurs only on windows on linux with the same tools gcc 3.4.5 and Qt 4.2.2 application does not close ... can anybody explain to me what makes that difference ???

wysota
9th December 2006, 23:37
My guess is the nature of the tray icon. On Linux it seems to be a window as well, so as long as it is open, the application won't quit. Simply call setQuitOnLastWindowClosed ( false ) on your QApplication object and you'll have a coherent behaviour.

tzioboro
10th December 2006, 17:12
This is how I solved this problem, by "I find out that reason is in QApplication::quitOnLastWindowClosed() which is default set to true" I mean it have to be set false :)
So it seems it that tray icon is window under linux only, even it does not have widget interface (at least to the programmer). Under windows it is not "counted" as last or any window at all.