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. Handle QmouseEvent for rightClickEvent and rightClickEvent+moveEvent seperately
Forum Updated to NodeBB v4.3 + New Features

Handle QmouseEvent for rightClickEvent and rightClickEvent+moveEvent seperately

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 186 Views
  • 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.
  • gde23G Offline
    gde23G Offline
    gde23
    wrote on last edited by gde23
    #1

    Hello,

    I want to show a menu on right click and use right mouse move for moving stuff around.

    So I've implemented both methods in :

    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent *event);.
    

    However now, when I move around, also the menu opens.
    So how can I distinguish between both cases.

    One option I thought of is using a QTimer to trigger the menu, that gets canceled by the move but is there a better option?

    Thanks in advance

    JonBJ 1 Reply Last reply
    0
    • gde23G gde23

      Hello,

      I want to show a menu on right click and use right mouse move for moving stuff around.

      So I've implemented both methods in :

      void mousePressEvent(QMouseEvent *event);
      void mouseMoveEvent(QMouseEvent *event);.
      

      However now, when I move around, also the menu opens.
      So how can I distinguish between both cases.

      One option I thought of is using a QTimer to trigger the menu, that gets canceled by the move but is there a better option?

      Thanks in advance

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @gde23
      Where are you doing all of this? You're just supposed to attach menus to widgets' QContextMenuEvent, QWidget::contextMenuEvent(QContextMenuEvent *event), etc.

      Oh, I think I see what you mean. Start by being more specific about "use right mouse move for moving stuff around.". Presumably you are talking about right mouse down and then drag/move around, else it wouldn't be interfering with the right-click context menu? So the trouble with your intention is that at right-mouse-down you still don't know whether to show a menu or start a drag? I don't think this is a good idea, I can't think of an application which deals with right-mouse-down ambiguously like this? I would try to think of one before you adopt this behaviour.

      1 Reply Last reply
      2

      • Login

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