Unsolved QSystemTrayIcon activated signal workaround
-
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.
-
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.