In this recipe, we will be learning to display lines of different types between two points, from the mouse click location to where the mouse button is released. The user will be shown different line types to choose from, such as solid, dash line, dash-dot line, and so on. The line will be draw in the selected line type.
Drawing lines of different types
How to do it...
It is the QPen class that is used for defining the size or thickness of the pen used for drawing shapes. The setStyle() method of the QPen class is used in this recipe to define the style of the line. Here is the step-by-step procedure to draw lines of different styles:
- Let's create an application based on the Dialog without Buttons template.
- Add a QLabel widget...