Results 1 to 9 of 9

Thread: mousePressEvent - Problems handling right and left mouse buttons together

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: mousePressEvent - Problems handling right and left mouse buttons together

    Quote Originally Posted by weevil View Post
    I was thinking there were two mouse press events occuring in the scenario I described, where the first is either a left or right button press, and the second event registers both left and right button presses. You make it sound like there's one event that registers a left click say, and the other registers a right click?
    I see what you mean.
    You can click the left mouse button and keep it pressed. There will be a left mouse button press event. It might be repeated too when holding it.
    Now, while you keep the left mouse button pressed, you press the right button. There will now be a new press event for the right button.
    They do not appear at the same time and the second press event is only for the right button.

    You then want to check if both press events happened in a certain amount of time (if necessary) or just check if they are both pressed independent of the time.

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: mousePressEvent - Problems handling right and left mouse buttons together

    Mouse events are always serialized; even if you manage to press both mouse buttons precisely at the same time, the OS is going to convert that into two seperate events and send them along one after the other.

    The best you can do is note the state of the event by examining buttons() and checking to see whether both buttons happen to be down, which will be the case for one of the pair of events you'll receive. If you want different behavior when only one button is down, though, the only way to implement that is to use an interval timer that determines when two clicks are "close enough" together to count as a single event.

Similar Threads

  1. Replies: 4
    Last Post: 30th May 2010, 12:55
  2. Emulating Enter key with left mouse click
    By wconstan in forum Newbie
    Replies: 6
    Last Post: 30th December 2009, 16:16
  3. how align some buttons in QToolbar from right to left?
    By davi_all4one in forum Qt Programming
    Replies: 3
    Last Post: 7th September 2009, 11:15
  4. combining Alt + Left Mouse Button
    By speedracer in forum Qt Programming
    Replies: 1
    Last Post: 3rd June 2009, 13:29
  5. left/right panel with buttons
    By swiety in forum Qt Programming
    Replies: 1
    Last Post: 5th January 2008, 13:12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.