How it works...
The triggered() signal of the action of each toolbar button is connected to the respective method. The triggered() signal of the actionCircle toolbar button is connected to the drawCircle() method, so whenever the circle toolbar button is selected from the toolbar, the drawCircle() method will be invoked. Similarly, the triggered() signal of actionRectangle and actionLine are connected to the drawRectangle() and drawLine() methods, respectively. In the drawCircle() method, a variable toDraw is assigned a string, circle. The toDraw variable will be used to determine the graphics to be drawn in the paintEvent() method. The toDraw variable can be assigned any of the three strings, line, circle, or rectangle. A conditional branching ...
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