⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

Qt-5 systray example problems

  • I'm running Ubuntu 14.04, and I’ve tried running the Qt 5.4 example widgets/desktop/systray but I'm getting the error: "I couldn't detect any system tray on this system." However, an older qt4.7 executable (non-related to this specific example) that has made use of QSystemTrayIcon works just fine. Any idea how to fix this?

  • One other thing, the qt-4.7 executable was not compiled on my system, so it appears to be something wrong with my current compiling system.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Can you check if you also experience this with the Qt 5 version from your distribution ?

  • So just to clarify, the Qt5 systray example is the one that I'm having problems with, it is the one that gives the error. I actually found a precompile (not from my system) Qt-4.7 systray executable, which is very similar in source code, with a few differences in Qt4/Qt5 formats. This Qt-4.7 precompiled systray example works. I can't figure out how to re-compile the 4.7 code on my system cause I'm a noob. I'm using the online installer form of qtcreator to do my compiling. I might be able to compile the 4.7 source code using qmake if I had some assistance. Thank you.

  • Breaking down the code a bit, it appears that there is an error in the way QT5 is reading QSystemTrayIcon::isSystemTrayAvailable(). I know that my system has it available, but Qt5 is not understanding it. I've tried to just comment out that area of the example code, but it runs the program without a systray icon; like having an invisible try icon.

  • Lifetime Qt Champion

    Again, are you experiencing the same if you use your distro Qt 5 packages ? If not then you can compare their sources and see if there's any patch applied by the Ubuntu devs.

  • Sorry I didn't understand what you wanted, I did try with my distro's Qt5 and its the same deal.

  • Ok, I want to thank you all for your help, I think I figured out what the problem was. Ubuntu 14.04 is not functional when it comes to Qt5 and QSystemTrayIcon. I have to use Qt4, which was just a matter setting the compiler options to compile with Qt4.8 instead of Qt5. I found 1 work around for Qt5 + SystemTray, but IMO it really wasn't that good, because it used gtk+ embedded into Qt5 which was ugly. Maybe Qt5 will work with the next LTS! Hopefully anyway.

  • Hi,
    I'm on Ubuntu 14.10. Here QSystemTrayIcon works with manually installed Qt 5.4 from qt.io and also with Qt 5 from the Ubuntu SDK.

  • The information I gave in the last post was incomplete. QSystemTrayIcon::isSystemTrayAvailable() returns true and a tray icon can be added to the tray but it's shown in the wrong place. This bug is said to be fixed in Qt 5.5.0 Alpha: https://bugreports.qt.io/browse/QTBUG-31762

Log in to reply