How to prevent QSystemTrayIcon's contextMenu from hiding when clicked?
-
I'm trying to enable the user to click on an action in a context menu multiple times without making
QSystemTrayIcon
'scontextMenu
hide, which happens by default.I tried to
show
thecontextMenu
when an action is triggered (clicked), so it makes it show up after hiding, but the problem with this is that thecontextMenu
will pop up at the top left corner of the screen, because it takes aQPoint(0,0)
I'm guessing, and it does not have the my system's theme as well. below is what I mean:normal
ContextMenu
:ContextMenu
that pops up at the top left corner when usingshow
:I also tried to emit
activated
signal withQSystemTrayIcon::Context
, but that did nothing, althoughQSystemTrayIcon::Trigger
works perfectly.I also tried installing an
EventFilter
on myQSystemTrayIcon
, but it captured no events, and the same event filter captured mouse press when installing it onQMenu
when clicking out of it, so I removed the suspicion of me not installing theEventFilter
properly.So in addition to the question in the title:
-
What is different between right-clicking the system tray icon to pop up the context menu and using
show
? Because their results are different. -
How can I simulate right-click to pop up
contextMenu
ofQSystemTrayIcon
, I tried sending amouseEvent
, but that is not possible becauseQSystemTrayIcon
does not have a global pos, so I can't provide aposition
toQMouseEvent
.
Thank you for your time and efforts! Any help or guidance is much appreciated.
-