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

QMenu for QSystemTrayIcon doesn't work correctly if we declare it after QQmlApplicationEngine load method

    XMLWordPrintable

Details

    • Windows

    Description

      If we declare (create) QMenu for QSystemTrayIcon after QQmlApplicationEngine load method (see main_incorrect.cpp at attachments) we have incorrect behaviour: the qmenu (right mouse click on QSystemTrayIcon item) doesn't disapear after outside click (not on the application window). Hovever, if we have declaration before the load method (see main_correct.cpp at attachments) we have absolute correct behaviour.

       

      If you have similar problem in your project, just insert the next code in your main{} block and after that you can create QMenu for QSystemTrayIcon anywhere:

      void bugFix()
      {
          QMenu *trayIconMenu = new QMenu();
          QSystemTrayIcon * trayIcon = new QSystemTrayIcon();
          trayIcon->setContextMenu(trayIconMenu);
          delete trayIcon;
          delete trayIconMenu;
      }
      

      Attachments

        1. main_correct.cpp
          1 kB
          Anatoliy Dudko
        2. main_incorrect.cpp
          1 kB
          Anatoliy Dudko
        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
            yoxfox Anatoliy Dudko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes