Let's try to make an item containing multiple children. We want to create a rectangle with a filled circle in each corner and be able to move and rotate it as a whole, like this:
First, you need to create a function that creates a single complex rectangle, by using the following code:
QGraphicsRectItem *createComplexItem( qreal width, qreal height, qreal radius) { QRectF rect(-width / 2, -height / 2, width, height); QGraphicsRectItem *parent = new QGraphicsRectItem(rect); QRectF circleBoundary(-radius, -radius, 2 * radius, 2 * radius); for(int i = 0; i < 4; i++) { QGraphicsEllipseItem *child = new QGraphicsEllipseItem(circleBoundary, ...