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

QSystemTrayIcon does not emit the QSystemTrayIcon::activated signal on Ubuntu 20.04/22.04 for left click and right click.

    XMLWordPrintable

Details

    • Linux/Wayland, Linux/X11
    • 9e251d44a79e171f093e89b21215d7372866ef4c

    Description

      QSystemTrayIcon does not emit the QSystemTrayIcon::activated signal on Ubuntu 20.04/22.04 for left click and right click

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

      private slots:
      void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
      
      private:
      QSystemTrayIcon* trayIcon_{};

      Also, an image has been added to the resources to display the icon.

      Here is the content of mainwindow.cpp:

      #include "mainwindow.h"
      #include "./ui_mainwindow.h"
      
      #include <QDebug>
      
      MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
          , ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      
          QIcon icon;
          icon.addFile(":/banana.png");
          trayIcon_ = new QSystemTrayIcon(icon, this);
          connect(trayIcon_, &QSystemTrayIcon::activated, this, &MainWindow::trayIconActivated);
      
          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();
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      
      void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
      {
          qDebug() << "trayIconActivated()" << reason;
      }
      
      
      

      The MainWindow::trayIconActivated() slot is ONLY called for the middle mouse button click. 

      This bug reproduces in Ubuntu 20.04/22.04 on Xorg and Wayland graphics servers.

      On Windows 11, QSystemTrayIcon::activated signals are generated for all mouse buttons.

      On Kubuntu 22.04 (Xorg graphics server), QSystemTrayIcon::activated signals are generated for the left, right, and middle mouse buttons (but not for left double-clicking).

      On Linux mint 20/21 Cinnamon (Xorg graphics server) QSystemTrayIcon::activated signals are generated for the left and middle mouse buttons (but not for left double click and right click).

       

      Attachments

        For Gerrit Dashboard: QTBUG-107727
        # Subject Branch Project Status CR V

        Activity

          People

            santhoshkumar Santhosh Kumar Selvaraj
            rumgot rumgot
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 4 hours
                1d 4h

                Gerrit Reviews

                  There is 1 open Gerrit change