Prevent app (with systray icon) from closing when last window is closed.
-
Hello
I made a small app that has a systray icon from where one can launch windows. My problem is that when I close the last window,
the application closes as well. How can I prevent this so that the user has to rightclick the tray icon and click quite? (the "quit" isn't the issue, only keeping the app alive) Thanks
Richard -
Reimplement closeEvent of your main widget
@protected:
void closeEvent(QCloseEvent *);@ -
@void TEST::closeEvent(QCloseEvent * e)
{
if(this->should_close)
e->accept():
else
e->ignore();
}@ -
Argh, sorry, havn't read you post exactly :)
try "this":http://qt-project.org/doc/qt-4.8/qapplication.html#quitOnLastWindowClosed-prop:
@qApp()->setQuitOnLastWindowClosed(false);@