Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.3
-
None
-
macOS Sonoma 14.5
Qt 6.5.3
Description
SystemTrayIcon has menu property. Which is great, but in many cases desired behavior is to activate app on left click and to open menu on right click. Which is impossible using this property, menu opens always out of the box.
However, onActivated handler can be used to detect right click, and to open menu. And here comes the issue. SystemTrayIcon remains in pressed state.
Run attached code.
Right click tray icon
Select any menu option
Observe tray icon. It gots stuck in pressed state.
import QtQuick import QtQuick.Controls import Qt.labs.platform Window { id: window width: 640 height: 480 visible: true title: qsTr("Hello World") SystemTrayIcon { visible: true icon.source: ":/icon.png" icon.mask: true onActivated: function(reason) { if (reason === SystemTrayIcon.Context) { menu.open() } else { window.show() window.raise() window.requestActivate() } } } Menu { id: menu MenuItem { text: "menu item 1" onTriggered: { window.show() window.raise() window.requestActivate() } } MenuItem { text: "menu item 2" } } }