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

if(event->buttons() == (Qt::LeftButton | Qt::RightButton))
code();
i have tested it and it works

but one question why do we use or operator and that too unary.