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

QSystemTrayIcon No tray icon displayed without calling setContextMenu() on Ubuntu.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Not Evaluated
    • None
    • 5.15.2, 6.2.4, 6.4.0
    • None
    • Linux/Wayland, Linux/X11

    Description

      QSystemTrayIcon No tray icon displayed without calling setContextMenu() on Ubuntu.

      There is a simple project created in Qt Creator (File - New Project - Application (Qt) - Qt Widgets Application). Added class member:

      QSystemTrayIcon* trayIcon_{};

      Also, an image has been added to the resources to display the icon. And then in the MainWindow constructor, there is the following code to add the tray icon:

      MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
          , ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      
          QIcon icon;
          icon.addFile(":/banana.png");
      
          trayIcon_ = new QSystemTrayIcon(icon, this);
          
          auto menu = new QMenu();
          menu->addAction("Action 0");
          menu->addAction("Action 1");
          menu->addAction("Action 2");
          menu->addAction("Action 3");
      
          trayIcon_->setContextMenu(menu);
          
          trayIcon_->show();
      }
      

       On Ubuntu 20.04 / 22.04 systems (on Xorg and Wayland sessions) the tray icon is displayed ONLY if the function trayIcon->setContextMenu(menu) is called otherwise the icon is not displayed.

      On the following operating systems, the icon is displayed without calling trayIcon->setContextMenu(menu) :

      • Linux mint 20 Cinnamon
      • Linux mint 21 Cinnamon
      • Kubuntu 22.04
      • 'Windows 11

      This bug has negative consequences in the form of the fact that if the application is minimized to the tray icon when closed, and the tray icon is not visible, then the application becomes impossible to close.

      Maybe it's a problem with the gnome graphical environment or not - I don't know.

      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
            rumgot rumgot
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes