How it works...
As we want to display a line between the locations where the mouse button is clicked and released, we will be making use of two methods, mousePressEvent() and mouseReleaseEvent(). As the name suggests, the mousePressEvent() method is automatically invoked when a mouse button is pressed. Similarly, the mouseReleaseEvent() method is automatically invoked when the mouse button is released. In these two methods, we will be simply saving the values of the x and y coordinates where the mouse button is clicked and released. Two arrays are defined in this application, pos1 and pos2, where pos1 stores the x and y coordinates of the location where the mouse button is clicked, and the pos2 array stores the x and y coordinates of the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access