QSystemTrayIcon issue on Ubuntu 16.04
Unsolved
General and Desktop
-
I'm using Qt 5.7.1 on Ubuntu 16.04. Basically I have an app which opens a widget when a click on tray icon is performed.
However when I click on the tray an ugly empty menu is displayed and the signal is not emitted at all.This works on OSX 10.12.2, Windows 10 and Fedora 21, Gnome 3.14
Can someone help me suggesting a workaround? It seems a Qt bug...
The code is the following:
main.cpp
#include <QApplication> #include "mytray.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); myTray w; return a.exec(); }
mytray.h
#pragma once #include <QSystemTrayIcon> class myTray : public QSystemTrayIcon { Q_OBJECT public: explicit myTray(QObject *parent=0); private slots: void showPopup(QSystemTrayIcon::ActivationReason); };
mytray.cpp
#include "mytray.h" #include <QMessageBox> myTray::myTray(QObject *parent) :QSystemTrayIcon(parent) { connect(this ,&QSystemTrayIcon::activated, this, &myTray::showPopup); //TODO: use an available icon setIcon(QPixmap(":/icon")); show(); } void myTray::showPopup(QSystemTrayIcon::ActivationReason) { QMessageBox::information(nullptr, "Hello", "Hello"); }
-
Hi,
Before calling it a Qt bug, you should test your application by building it with Ubuntu's provided Qt. They might have done customisation for their window manager.
-
Just out of curiosity, is this on unity desktop ?