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

Windows: Two menus instead of one appear by clicking on the QSystemTrayIcon

    XMLWordPrintable

Details

    • Windows
    • b71aa3c66 (dev), 7ea394eed (6.6), 08dfed7e1 (tqtc/lts-6.5), 3db071093 (tqtc/lts-6.2), 63a58e072 (tqtc/lts-5.15)

    Description

      It seems like the method setContextMenu in QSystemTrayIcon class doesn't work correctly.

      On Windows, after calling the setContextMenu, provided that another (not old) menu is added, when you click on the tray, both the old and the newly added menu appear instead of the expected only new menu.

      I have a suspicion that the problem is in the wrong disconnect in the QSystemTrayIcon::setContextMenu method (in qsystemtrayicon.cpp). After some checks on the status of the old menu, the necessary disconnection occurs. But the problem is that disconnect occurs for the new (added) menu, not for the old one.

      if (oldMenu && !oldMenu->platformMenu())
          QObject::disconnect(d->qpa_sys, &QPlatformSystemTrayIcon::contextMenuRequested, menu, nullptr);
      

      The attached file contains simple example. After pressing the first button ("Set Menu1 (red)") a red menu appears in the tray icon. But after pressing the second button ("Set Menu2 (blue)") a blue menu appears along with the red one.

      This code was tested on 5.12.4 and 5.13.1 Qt versions.

      Attachments

        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
            silverywhite Pavel Gatin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: