QGraphicsView, QGraphicScene and QGraphicsItem provide a way for applications based on Qt Widgets to show 2D graphics.
The source code can be found on the Git repository under the Chapter01-graphicsview directory, in the cp1 branch.
Every QGraphicsView needs a QGraphicsScene. Every QGraphicsScene needs one or more QGraphicsItem.
QGraphicsItem can be any of the following:Â
- QGraphicsEllipseItem
- QGraphicsLineItem
- QGraphicsLineItem
- QGraphicsPathItem
- QGraphicsPixmapItem
- QGraphicsPolygonItem
- QGraphicsRectItem
- QGraphicsSimpleTextItem
- QGraphicsTextItem
Qt Designer has support for adding QGraphicsView . You can follow these steps to do so:
- Drag the QGraphicsView to a new application form and fill the form with a QGridLayout like we did before.
- Implement a QGraphicsScene in the source code and add it to the QGraphicsView
QGraphicsScene...