QSystemTrayIcon tool tip not showing on mouse hover

  • I have setup a QSystemTrayIcon with a tool tip but it doesn't show up on mouse hover. I'm running Qt 5.8 on Ubuntu 17.04

    Here is the setup code:

    QSystemTrayIcon *m_pTrayIcon  = new QSystemTrayIcon(this);
    QIcon icon(*m_pImage);
    m_pTrayIcon->setToolTip(tr("ToolTip Test));

    I do not see the tool tip show on mouse hover over the system tray icon. Do I need to capture a mouse hover event in order to have this shown?

  • Lifetime Qt Champion

    @anshah said in QSystemTrayIcon tool tip not showing on mouse hover:


    m_ prefix is usually used for class members, but you're declaring a new local variable here:

    QSystemTrayIcon *m_pTrayIcon  = new QSystemTrayIcon(this);

    Where is this code executed? Do you have a class member called m_pTrayIcon? Did you make sure m_pImage is a valid image?

  • @jsulm
    So m_pTrayIcon is a class member I just added for the purposes of clarity so you could see the type. Yes, m_pImage is a valid image. Everything works fine...I am just not getting a tool tip to show.

  • Hmm, I have a program that also uses QSystemTrayIcon, and the tool tip text is shown both on my Windows 7 and my Windows 10 PCs, here's the code:

    trayIconMenu = new QMenu(this);
    pTrayIcon = new QSystemTrayIcon(this);
    pTrayIcon->showMessage("balloon title","balloon message");
    pTrayIcon->setToolTip("this is the tooltip");

    Edit: sorrry didn't see until now that your'e not on Windows. I tried the above code on my Ubuntu 18.04 with Qt 5.13.0, while everything works the same as on Windows PCs except there's no tooltip text visible :-(

    Maybe some design limit in Ubuntu's desktop...

  • @hskoglund
    Thanks for the reply! Looks like your using everything latest and greatest. I'm using Qt 5.8 on Ubuntu 17.04.
    Maybe this is a design limitation on Ubuntu. If any of you "QT Champions" can confirm this that would be great!

    Also, same deal on CentOS, RHEL, Fedora?

  • Lifetime Qt Champion


    Are you using the Qt version that comes with your distribution ?

    From what I remember, the Ubuntu guys used to patch Qt to integrate with their desktop shell.

  • @sgaist I'm using a Qt 5.8 manual install.

  • Lifetime Qt Champion

    Then, please try the version provided by the distribution just to check if it behaves as expected.

  • @SGaist Sorry for the long delay in response as I got pulled off to other issues now I'm back on this one. So to answer your question I tried again with the Qt Version that comes with my Ubuntu distribution and the tooltip still does not pop up.

    I'm am using Ubuntu 18.04 with Gnome Desktop (3.28.2) .

Log in to reply