Details
-
Bug
-
Resolution: Fixed
-
Not Evaluated
-
None
-
5.15.2, 6.2.4, 6.4.0
-
None
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.