Have a go hero – Reacting only to the left mouse button

As an exercise, you can modify the event handling code so that it only changes the selection if the mouse event was triggered by the left mouse button. To see which button triggered the mouse press event, you can use the QMouseEvent::button() method, which returns Qt::LeftButton for the left button, Qt::RightButton for the right, and so on.

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.