Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-119065

Unable to reset tray icon menu for QML SystemTrayIcon

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.5.4, 6.6.1, 6.7.0 FF
    • 6.5.3, 6.6.0
    • Quick: Other
    • None
    • macOS
    • 3ad1980ef (dev), f7ef1800a (6.6), 2431e7a91 (tqtc/lts-6.5)

    Description

      Sample code:

      import QtQuick
      import QtQuick.Controls
      import Qt.labs.platform as Platform
      
      Window {
          width: 640
          height: 480
          visible: true
      
          Platform.Menu {
              id: trayMenu
              Platform.MenuItem {
                  text: qsTr("Quit")
                  onTriggered: Qt.quit()
              }
          }
      
          Platform.SystemTrayIcon {
              id: trayIcon
              visible: true
              icon.source: "https://img.icons8.com/emoji/96/teddy-bear-.png"
              menu: trayMenu
          }
      
          Button {
              text: trayIcon.menu ? 'Remove Tray Menu' : 'Set Tray Menu'
              onClicked: trayIcon.menu = trayIcon.menu ? null : trayMenu
          }
      }
      

      Just launch it and click on tray icon (Teddy Bear ) - menu is displayed - OK
      Press on 'Remove Tray Menu' button and click on tray icon again - menu is still displayed - BUG.
      Continue clicking on 'Set Tray Menu'/ 'Remove Tray Menu' and observe tray icon menu behaviour, you'll find it completely unpredictable. Also in the debug output there are warnings, such as

      qt.qpa.menus: Menu item "Quit" already in menu ""
      qt.qpa.menus: Menu item "Quit" already in menu "Untitled"
      qt.qpa.menus: Menu item "Quit" already in menu "Untitled"
      ...
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              studiosus Vladimir Belyavsky
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes