Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt closing tray icon after application stops

I've a little problem with tray icon under windows. After my Qt application stopps (normal exit) the icon still remains in system bar. It disapears only when I move mouse cursor over it. I tried to hide it in the destructor of my window but it fails: I tried .setVisible(false).

Any ideas? Thanks.

P.S. I remember I had the same problem with SWT/Java.

like image 950
Sebastian Dusza Avatar asked Mar 27 '11 12:03

Sebastian Dusza


2 Answers

I wouldn't hide it in the destructor. It will likely be an invalid reference at that point. I would put it in where your event for "Exit" happens.

like image 156
Daniel A. White Avatar answered Sep 23 '22 14:09

Daniel A. White


If you're not able to call it from a destructor, you could connect the QCoreApplication::aboutToQuit() signal to the QSystemTrayIcon::hide() slot.

like image 33
Anigif Avatar answered Sep 22 '22 14:09

Anigif