No, it won't work. button() will return only one of the buttons. Using QMouseEvent::buttons() seems better though.
No, it won't work. button() will return only one of the buttons. Using QMouseEvent::buttons() seems better though.
the right click followed by leftclick(vice-versa) where the former is still active .does this not work
in other words
if( (mouseEvent->button() == Qt::LeftButton)
{
if(mouseEvent->button() == Qt::RightButton))
{
//your code
}
}
Last edited by babu198649; 20th November 2007 at 10:36.
I don't know what you meanBut your code is faulty - you are missing one equality sign ('=') before Qt::RightButton.
ok thanks for pointing out error i will try and will post my result i have edited the bug in the previous post.
To me the proper way of doing what the thread author wants is:
Qt Code:
if(e->buttons() & (Qt::LeftButton|Qt::RightButton)) doSomething(); else baseClass::mousePressEvent(e); }To copy to clipboard, switch view to plain text mode
One might also use == instead of & depending on the effect one wants to obtain.
i tried u r code it enters if condition even if one button is clicked .but the author of post wants only when both the buttons are active.
this can be done by
i have tested it and it worksif(event->buttons() == (Qt::LeftButton | Qt::RightButton))
code();
but one question why do we use or operator and that too unary.
Bookmarks