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. QMenu as widget right click context menu blocks mouse events
Forum Updated to NodeBB v4.3 + New Features

QMenu as widget right click context menu blocks mouse events

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.6k 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.
  • S Offline
    S Offline
    schij
    wrote on 4 Nov 2013, 20:00 last edited by
    #1

    I have implemented a QMenu for a Widget as follows:

    void MyWidget::mousePressEvent( QGraphicsSceneMouseEvent* event )
    {
    ....
    if( event->button() == Qt::RightButton )
    {
    QMenu* myMenu = new QMenu();
    myMenu->addAction("Send Blend To Projector", this, SLOT( sendBlendToSelectedProj() ) );
    myMenu->popup( QCursor::pos() );
    }
    ....
    }

    The popup menu still grabs the mouse event; when I click on another widget I want to popup it own menu after the first one closes; this doesn't happen while the first popup menu is displayed. Based on what I read in the documentation, the popup is nonModal and should not capture mouse events.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 5 Nov 2013, 07:15 last edited by
      #2

      i believe when you use Qmenu::popup() to show the menu it's window flags are also set to "Popup". Meaning that the mouse event is just to be used for closing.
      You can try just to use move() and show(). But then you would have to take care that your you close your menu by yourself.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • S Offline
        S Offline
        schij
        wrote on 5 Nov 2013, 13:48 last edited by
        #3

        I tried using myMenu->exec and myMenu ->show and they all block the mouse; I tried installing an event filter on the widget to make myMenu ignore the right click; this works partially, as myMenu now ignores the mouse right click , but the event is not being picked up by the second widget.

        Basically what I am trying to implement is behavior similar with a right click in MS Excel: when the user right clicks on a cell, the cell gets selected and the context menu shows up; right clicking on another cell selects that cell and shows it's context menu. Can anybody point me in the right direction? Thanks

        1 Reply Last reply
        0

        1/3

        4 Nov 2013, 20:00

        • Login

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