In this recipe, we will learn to display a line between two points, from where the mouse button is clicked till where the mouse button is released on the form. The focus of this recipe is to understand how the mouse press and release events are handled, how the x a and y coordinates where the mouse button is clicked and released are accessed, and how a line is drawn from the location where the mouse button is clicked to the location where the mouse button is released.
Drawing a line between two mouse clicks
How to do it...
The major players in this recipe are the mousePressEvent(), mouseReleaseEvent(), and paintEvent() methods. The mousePressEvent() and mouseReleaseEvent() methods are automatically executed whenever the mouse button...