Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make Qt application not to quit when last window is closed

Tags:

c++

qt

I've created a Qt application that acts mostly as a daemon, but occasionally shows a dialog.

Now, I know the default behavior is to close the application when the last window closes, but for my program, I need it to continue running. How do I change the behavior of my application?

like image 348
sashoalm Avatar asked Nov 06 '13 11:11

sashoalm


1 Answers

You can set the QApplication::quitOnLastWindowClosed property to false:

...
QApplication qApp;
qApp.setQuitOnLastWindowClosed(false);
...
like image 105
Andreas Fester Avatar answered Sep 21 '22 18:09

Andreas Fester