Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. right-click

    Log in to post
    • All categories
    • B

      Solved Multiple actions on right click on label
      General and Desktop • action right-click label • • BigBen

      3
      0
      Votes
      3
      Posts
      100
      Views

      JonB

      @BigBen
      When you go QMenu::addAction("SomeString") it creates a QAction for you, and returns it. And QMenu::exec() returns the QAction which was clicked. So you could check which one is returned and act on it, like:

      QAction *hideAction = myMenu.addAction("Hide"); QAction *showAction = myMenu.addAction("Show"); QAction* selectedAction = myMenu.exec(globalPos); if (selectedAction == hideAction) qInfo() << "Hide"; else if (selectedAction == showAction) qInfo() << "Show";

      Alternatively, when you create the QActions you could attach a slot to its triggered signal:

      connect(hideAction, &QAction::triggered, this, []() { qInfo() << "Hide"; } );
    • L

      Solved Check if button was right clicked or left clicked?
      General and Desktop • right-click button qmouseevent • • legitnameyo

      15
      0
      Votes
      15
      Posts
      4431
      Views

      L

      Solved it by creating a derivative of the CustomQPushButton class definition! Thanks!

    • L

      Solved Mouse pressed with right OR left click check?
      General and Desktop • click qpushbutt right-click • • legitnameyo

      5
      0
      Votes
      5
      Posts
      4747
      Views

      jsulm

      @legitnameyo This is not how it works. You will need to subclass QPushButton and override http://doc.qt.io/qt-5/qwidget.html#mousePressEvent
      You can find an example here: http://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html

    • M

      QMenu blocks mouse events
      General and Desktop • mouseevent right-click qmenu • • m_jero

      2
      0
      Votes
      2
      Posts
      1056
      Views

      D

      @m_jero I don't know why nobody answers this question. Maybe because you didn't supply any code snippets as recommended. Anyway, I suppose you used the exec() function to show the qmenu. Try to use popup() instead and see if it works.

    • K

      Can't use right-click in Qt
      General and Desktop • right-click • • Kakalof

      8
      0
      Votes
      8
      Posts
      1501
      Views

      K

      Alright, really strange, but just pulled mouse out tried touch pad. Guess what, just acted normal, put mouse back in no problem either. Pulled the mouse out earlier but didn't work then, don't know what changed but the problem is solved. (By the way, it was a cheap mouse with only 4 buttons :))

      Thanks to both of you for your help and fast response.