Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSystemTrayIcon not showing on certain Linux distros.
Forum Updated to NodeBB v4.3 + New Features

QSystemTrayIcon not showing on certain Linux distros.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bart_Vandewoestyne
    wrote on last edited by
    #1

    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:

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

    And in our code, we refer to it as

      mpQTrayIcon = new QSystemTrayIcon();
      mpQTrayIcon->setIcon(QPixmap(":/SomeIcon.ico"));
    

    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?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      SomeIcon.ico

      You forgot to distribute the ico plugin

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      B 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

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

        SomeIcon.ico

        You forgot to distribute the ico plugin

        B Offline
        B Offline
        Bart_Vandewoestyne
        wrote on last edited by
        #3

        @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/libqico.so 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.

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved