Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QSystemTrayIcon in Linux



  • I'm working in an app that creates a TrayIcon on the system, it's working perfectly on Windows but it's not showing in linux. I'm not sure if it's the version of linux. I left here the code I'm ussing.

     if (QSystemTrayIcon::isSystemTrayAvailable()) {
        trayIcon = new QSystemTrayIcon(this);
        trayIcon->setIcon(QIcon(":/Imagenes/iconosPERFQ-23.png"));
        trayIcon->setToolTip(tr("PerfQ Client"));
        trayIcon->setVisible(true);
        connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
                     this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
    }

  • Lifetime Qt Champion

    Hi,

    Did you check whether isSystemTrayAvailable returns false ?

    If not, what distribution are you using ?



  • I have a similar problem. The tray icon in Linux is shown in the top left corner instead of the right bottom corner, if I run the application as normal user. That happens on Debian 7.
    On Windows and Mac all well.



  • @mrdebug do you use KDE? Have saw same issue on KDE4 Desktop using Qt4 apps.

    @SujaMM Which Linux distribution do you use and which Desktop environment?



  • Debian 7 with kde 4.8.4
    But if I run my application from user console as root user by sux, the tray icon will be right, in the bottom right corner of the screen.



  • Hi everyone,
    this bug is fixed in Qt 5.5.0 Alpha; see: https://bugreports.qt.io/browse/QTBUG-31762



  • The trayIcon it's only apearing when I run the runable create in the build folder, how ever it dosen't show when I run it on Qt Creator or from the terminal.
    The other problem it's that I detroy the trayicon when I close each window and create a new one to avoid having a buch of trayicons in the system tray. But this it's not working in linux.


Log in to reply