Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QSystemTrayIcon not showing in notification area on Ubuntu 14.04

Tags:

c++

ubuntu

qt

qt5

I'm writing an application that uses an QSystemTrayIcon. Everything works as expected, but the icon does not show up in the Unity notification area on the top right but just in the upper left corner.

The current build environment is clang 3.4, QT 5.3 on Ubuntu 14.04. When cross-compiling with MinGW and running the app in wine, the icon shows up correctly.

Is this maybe a missing setting in Ubuntu?

Here's a simple snippet that produces the same behavior:

#include <QSystemTrayIcon>
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QPixmap pixmap(32, 32);
    pixmap.fill(Qt::red);

    QIcon icon(pixmap);

    QSystemTrayIcon trayIcon(icon);

    QObject::connect(&trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), &app, SLOT(quit()));

    trayIcon.show();

    return app.exec();
}
like image 654
Hurzelchen Avatar asked Jul 14 '14 08:07

Hurzelchen


1 Answers

The issue you describe is a known and currently unfixed bug. See https://bugreports.qt.io/browse/QTBUG-31762

Workaround:

sudo apt-add-repository ppa:gurqn/systray-trusty
sudo apt-get update
sudo apt-get upgrade
like image 133
jans Avatar answered Oct 06 '22 06:10

jans