Results 1 to 9 of 9

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2010
    Posts
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1

    Default mousePressEvent - Problems handling right and left mouse buttons together

    I have a board widget comprised of a bunch of cell widgets arranged in a grid layout. In the cell class I reimplemented the mouse event functions, but I'm having trouble dealing with clicks on a cell with both the right and left mouse buttons. The cell can recognize when both buttons are pressed, but it receives a prior mousePressEvent with either the right or left mouse button depending on which came first in the multi-button click. I'm not sure if it's possible to avoid this, but I don't want the widget to receive a single mouse button click before the event has both clicks. I also don't want to implement some kind of timer delay that will make my single mouse clicks seem laggy, if I'm expressing that coherently.

    Right now my code looks like

    Qt Code:
    1. void Cell::mousePressEvent( QMouseEvent *event )
    2. {
    3. Qt::MouseButtons mouseButtons = event->buttons();
    4. if( mouseButtons == (Qt::LeftButton | Qt::RightButton) )
    5. { ... }
    6. else if( mouseButtons == Qt::LeftButton )
    7. { ... }
    8. else if( mouseButtons == Qt::RightButton )
    9. { ... }
    10. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by weevil; 10th June 2010 at 04:53.

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.