elams
elams

Reputation: 99

Make application not quit even if Main window is closed

I want the application to run in background even if the main window is closed.

I checked this one out and tried it but the application exits when I explicitly press exit button. I want the application to run in background even if I press exit explicitly.

I tried this

QApplication qApp;
qApp.setQuitOnLastWindowClosed(false);

Upvotes: 4

Views: 143

Answers (2)

user11818134
user11818134

Reputation: 1

Use the concept of Daemon thread of multi-threading for the same. The thread continues to run even when the program is executed or exited.

Upvotes: 0

Danil Karpov
Danil Karpov

Reputation: 101

I think it's better for you to just try hiding main QWidget of your application using setVisible(false)

After that you'll need some way to open your main window back again(tray menu is first option I can come up with) with setVisible(true)

Upvotes: 5

Related Questions