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'scontextMenuhide, which happens by default.I tried to
showthecontextMenuwhen an action is triggered (clicked), so it makes it show up after hiding, but the problem with this is that thecontextMenuwill 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:
ContextMenuthat pops up at the top left corner when usingshow:
I also tried to emit
activatedsignal withQSystemTrayIcon::Context, but that did nothing, althoughQSystemTrayIcon::Triggerworks perfectly.I also tried installing an
EventFilteron myQSystemTrayIcon, but it captured no events, and the same event filter captured mouse press when installing it onQMenuwhen clicking out of it, so I removed the suspicion of me not installing theEventFilterproperly.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
contextMenuofQSystemTrayIcon, I tried sending amouseEvent, but that is not possible becauseQSystemTrayIcondoes not have a global pos, so I can't provide apositiontoQMouseEvent.
Thank you for your time and efforts! Any help or guidance is much appreciated.
-