PDA

View Full Version : Systray application close after dialog shown



^NyAw^
30th March 2015, 12:48
Hi,

I have an application that has a system tray icon. When the application is closed by the X button it is minimized to tray. The tray icon have a "exit" action to let it quit. The application opens a serial port and when it reads data it opens a dialog that ask the user what to do.
After closing this dialog the aplication exits.
If the application is not minimized to systray the application does not exits and work as expected.

Any idea what is happening?

I'm using Qt 5.4.1 on Windows 7 with Visual Studio 2013

Thanks,

Lesiok
30th March 2015, 13:46
Is this dialogue the only window in both cases ? I think that problem is QApplication::quitOnLastWindowClosed.

^NyAw^
30th March 2015, 15:59
Hi,

No, I have a MainWindow and a Dialog but I think that you are in the good direction. When the user closes the application I call "hide()" and ignore the CloseEvent.

I have done a trick. Before showing the Dialog I call "showMinimized" so the main Window is shown on the taskbar and when the Dialog is closed I call "hide" again to let the application only appear on the system tray.

Thanks,

Added after 1 6 minutes:

Hi,

Finally the solution: "setQuitOnLastWindowClosed(false)" to the application works like expected.

Thank you,

^NyAw^
30th March 2015, 17:32
Hi,

The problem now is that if I minimize all windows using "Windows+D" I cannot force the dialog to be shown after a new serial port reading of data.
The Dialog is now a pointer and it is created every time I read the "correct" data from the serial port. I can make it to show again only using "Windows+Tab" as it doesn't have a taskbar icon.

I have tryied to call "show" , "raise", with no luck. Also I have tryied to call "show" and "raise" when double clicking on the system tray icon but the dialog still does not appear.

Thanks,