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::MouseButtons mouseButtons = event->buttons();
if( mouseButtons == (Qt::LeftButton | Qt::RightButton) )
{ ... }
else if( mouseButtons == Qt::LeftButton )
{ ... }
else if( mouseButtons == Qt::RightButton )
{ ... }
}
void Cell::mousePressEvent( QMouseEvent *event )
{
Qt::MouseButtons mouseButtons = event->buttons();
if( mouseButtons == (Qt::LeftButton | Qt::RightButton) )
{ ... }
else if( mouseButtons == Qt::LeftButton )
{ ... }
else if( mouseButtons == Qt::RightButton )
{ ... }
}
To copy to clipboard, switch view to plain text mode
Bookmarks