Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.15.2, 5.15.11, 6.2.4, 6.4.0
-
-
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 |
443981,4 | doc: update the limitation of QSystemTrayIcon on X11 | 6.4 | qt/qtbase | Status: NEW | +2 | 0 |