e already a variable. Just use:
void mouseReleaseEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton)
Operator
A switch also works. I prefer the if -- else if series because they simplify the handling of evente modifiers, i.e. e->modifiers() to check alt or control clicks. The if series is short enough not to create any load on the program.
EDIT: note that you should use the button() function, not its plural version of buttons() . See explanation in @ Merlin069's answer.
rpsml source share