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. How to prevent QSystemTrayIcon's contextMenu from hiding when clicked?
Forum Updated to NodeBB v4.3 + New Features

How to prevent QSystemTrayIcon's contextMenu from hiding when clicked?

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

    I'm trying to enable the user to click on an action in a context menu multiple times without making QSystemTrayIcon's contextMenu hide, which happens by default.

    I tried to show the contextMenu when an action is triggered (clicked), so it makes it show up after hiding, but the problem with this is that the contextMenu will pop up at the top left corner of the screen, because it takes a QPoint(0,0) I'm guessing, and it does not have the my system's theme as well. below is what I mean:

    normal ContextMenu:

    normal.png

    ContextMenu that pops up at the top left corner when using show:

    notNormal.png

    I also tried to emit activated signal with QSystemTrayIcon::Context, but that did nothing, although QSystemTrayIcon::Trigger works perfectly.

    I also tried installing an EventFilter on my QSystemTrayIcon, but it captured no events, and the same event filter captured mouse press when installing it on QMenu when clicking out of it, so I removed the suspicion of me not installing the EventFilter 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 of QSystemTrayIcon, I tried sending a mouseEvent, but that is not possible because QSystemTrayIcon does not have a global pos, so I can't provide a position to QMouseEvent.

    Thank you for your time and efforts! Any help or guidance is much appreciated.

    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