Reputation: 279
I have a QSystemTrayIcon
, that displays a QMenu
on click, but I want to display the menu as soon as the tray icon is displayed. I have tried calling the show
method on the QMenu
, but the menu only seems to display when it is clicked. Any idea on how to change this behaviour?
Upvotes: 2
Views: 1060
Reputation: 62777
I'm not sure if it's possible to trigger the behaviour triggered by operating system when user clicks the system tray, but at least you should be able to use QMenu::popup method to just show the menu returned by QSystemTrayIcon::contextMenu method.
Note that you should use the menu's size hint, when you calculate the menu postion relative to QSystemTrayIcon::geometry. Also you may need to use QDesktopWidget::availableGeometry to make sure the menu pops up inside the screen, no matter where the task bar is.
Upvotes: 1