In this section, we will learn how to draw simple vector shapes (a line, a rectangle, a circle, and so on) and display text on the main window using the QPainter class. We will also learn how to change the drawing style of these vector shapes using the QPen class.
Let's follow the steps listed here to display basic shapes in our Qt window:
- First, let's create a new Qt Widgets Application project.
- Open up mainwindow.ui and remove the menuBar, mainToolBar, and statusBar objects so that we get a clean, empty main window. Right-click on the bar widgets and select Remove Menu Bar from the pop-up menu:
- Then, open up mainwindow.h file and add the following code to include...