I installed the system tray icon for my application and connected a simple context menu to it. If I right-click on the icon to open the context menu, it works fine. If I then click somewhere that loses the focus of the application (for example, in another place on the taskbar or in another application), the context menu will not be deleted and still causes the correct action when clicked. If, however, I click on the main application, the context menu disappears as expected.
Here is the appropriate code for creating the tray icon and context menu -
actionExit = new QAction( "Exit", this );
connect( actionExit, SIGNAL( triggered() ), this, SLOT( ExitClient() ));
myTrayIconMenu = new QMenu( this );
myTrayIconMenu->addAction( actionExit );
trayIcon = new QSystemTrayIcon( icon, this );
trayIcon->setContextMenu( myTrayIconMenu );
connect( systrayIcon, SIGNAL( activated( QSystemTrayIcon::ActivationReason )),
this, SLOT( ToggleVisibility( QSystemTrayIcon::ActivationReason )));
trayIcon->show( );
, , , ? , .
[ Windows 7, Visual Studio 2010 Pro Qt - ]
API -
. . , , , .
myTrayIconMenu = new QMenu( );
myTrayIconMenu = new QMenu( this );
, . , .
?