Important: Please read the Qt Code of Conduct -

QSystemTrayIcon not showing on certain Linux distros.

  • I am trying to get rid of a QSystemTrayIcon warning that occurs when we run a legacy Qt 4.8.7 application on several flavors of Linux (in VMs), being

    • Red Hat Enterprise Linux Server 7.2 64-bit running GNOME 3.14.2
    • Red Hat Enterprise Linux 8.5 64-bit running GNOME 3.32.2
    • Debian GNU/Linux 8 (jessie) 64 bit running GNOME 3.14.1
    • Debian GNU/Linux 9 (stretch) 64-bit running GNOME 3.22.2

    The warning that we get is:

    QSystemTrayIcon::setVisible: No Icon set

    The strange things is as follows: I build the software on 2 VMS, namely:

    A) A Debian 8 VirtualBox VM running on my laptop. This Debian 8 VM also has a GNOME desktop environment installed.

    B) A Debian 8 Hyper-V MV running on one of our servers. This Debian 8 VM does not have a GNOME desktop environment installed. It is our Jenkins build slave and we only access it using SSH (command line, no X environment).

    The VirtualBox VM has quite a bit more Debian packages installed than the Hyper-V VM.

    Now the strange thing is as follows:

    If I compile and run the application on the VirtualBox VM, the icon is visible and we don't get the warning.

    If I compile exactly the same source on the Hyper-V VM, then copy the installer to the VirtualBox VM, install it and test it, the icon is not there and I do get the QSystemTrayIcon warning. So one could think that there is something wrong with this build... however.. now comes the very strange thing:

    If I ssh from the VirtualBox VM to the Hyper-V VM with X forwarding enabled (-X), and then start the application, the icon is visible and I don't get the warning.

    We use the Qt 4.8.7 Resource System to specify the path to the icon file:

    <RCC version="1.0">
            <file alias="SomeIcon.ico">images/SomeIcon.ico</file>

    And in our code, we refer to it as

      mpQTrayIcon = new QSystemTrayIcon();

    In the build output, I also see no errors or warnings when the .qrc file is resource compiled to a qrc_foobar.cpp file, nor do I see errors or warnings when the qrc_foobar.cpp file is compiled.

    For as far as I know, the Qt Resource System has a s a result that the content of the .ico file is actually in the binary executable file, so why is that icon shown in certain situations and in other situations not? Any suggestions on how to further debug this?

  • Lifetime Qt Champion

    @Bart_Vandewoestyne said in QSystemTrayIcon not showing on certain Linux distros.:


    You forgot to distribute the ico plugin

  • @Christian-Ehrlicher said in QSystemTrayIcon not showing on certain Linux distros.:

    You forgot to distribute the ico plugin

    Correct. Thanks! The directory with the application executable did not have the imageformats/ plugin shared object file. After adding that, the icon is now nicely shown.

    The fact that it worked under some circumstances was probably because in those circumstances, the plugin got loaded from our build directory (not from the deployed directory). Setting the QT_DEBUG_PLUGINS environment variable to some non-zero value helped seeing that.

Log in to reply