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

QSystemTrayIcon activated signal only sends on double click (Ubuntu/Gnome)



  • I am using Ubuntu 18.04 with Gnome desktop and seeing the the activated signal only emits when double-clicking on the icon. I need to have emit on single click:

    connect(m_pTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
            this,        SLOT(onActivated(QSystemTrayIcon::ActivationReason)));
    
    // Slot to handle tray icon activated signal
    void MyClass::onActivated(QSystemTrayIcon::ActivationReason r)
    {
        if (r == QSystemTrayIcon::Trigger)
        {
            if (!this->isVisible())
            {
                this->show();
            }
            else
            {
                this->hide();
            }
        }
    }
    

    I want to be able to either:

    • emit activated signal on single mouse click

    • detect a single mouse click event on the system tray icon


  • Lifetime Qt Champion

    @anshah I don't use Gnome, but is it possible that this is default behaviour?



  • @jsulm It seems like this is default behavior for Gnome. However, on Unity desktop it only needs a single click.


Log in to reply