Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.11.2, 5.12.0
-
None
Description
If we declare (create) QMenu for QSystemTrayIcon after QQmlApplicationEngine load method (see main_incorrect.cpp at attachments) we have incorrect behaviour: the qmenu (right mouse click on QSystemTrayIcon item) doesn't disapear after outside click (not on the application window). Hovever, if we have declaration before the load method (see main_correct.cpp at attachments) we have absolute correct behaviour.
If you have similar problem in your project, just insert the next code in your main{} block and after that you can create QMenu for QSystemTrayIcon anywhere:
void bugFix() { QMenu *trayIconMenu = new QMenu(); QSystemTrayIcon * trayIcon = new QSystemTrayIcon(); trayIcon->setContextMenu(trayIconMenu); delete trayIcon; delete trayIconMenu; }