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 activated signal workaround
Forum Updated to NodeBB v4.3 + New Features

QSystemTrayIcon activated signal workaround

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 324 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.
  • A Offline
    A Offline
    anshah
    wrote on last edited by
    #1

    It is well documented that the QSystemTrayIcon::activated signal doesn't work on Ubuntu Unity. In order to get around this I am using the QSystemTrayIcon context menu's QMenu::aboutToShow signal to capture mouse clicks.

    // Create tray and setup tray icon
    void MyClass::createTrayIcon()
    {
        m_pTrayIconMenu = new QMenu(this);
        m_pTrayImage    = new QPixmap(MY_IMAGE);
        m_pTrayIcon     = new QSystemTrayIcon(this);
    
        m_pTrayIcon->setContextMenu(m_pTrayIconMenu);
    
        QIcon icon(*m_pTrayImage);
        m_pTrayIcon->setIcon(icon);
        setWindowIcon(icon);
        m_pTrayIcon->show();
    
        connect(m_pTrayIconMenu, SIGNAL(aboutToShow()),
                        this,                              SLOT(onActivated()));
    }
    

    Though this is working fine except the context menu is showing still. Is there any way to suppress the context menu from showing at all? I realize I'm piggybacking the QMenu::aboutToShow signal because the QSystemTrayIcon::activated signal does not go out in Unity, but if you guys have any ideas that would be great! I see this on all Unity versions Ubuntu 14.04+. I do not see this issue on GNome.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      tried on win 10 but it does not show the menu.
      I was wondering if we subclass QMenu and override
      paintEvent and draws nothing if something would still show?
      I dont have unity to test on.

      1 Reply Last reply
      0

      • Login

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