First, create a new Qt Widgets Application project. After that, open mainwindow.ui and drag and drop the Graphics View widget onto the main window, like this:
Then, create a layout for the graphics view by clicking on the Lay Out Vertically button at the top of the canvas. After that, open up mainwindow.h and add the following headers and variables:
#include <QGraphicsScene> #include <QGraphicsRectItem> #include <QGraphicsEllipseItem> #include <QGraphicsTextItem> #include <QBrush> #include <QPen> private: Ui::MainWindow *ui; QGraphicsScene* scene;
After that, open mainwindow.cpp. Once it is opened, add the following ...