QGraphicsRectItem* rect = new QGraphicsRectItem(0, 0, 100, 100); rect->setPos(50, 50); scene->addItem(rect);
QGraphicsEllipseItem* ellipse = new QGraphicsEllipseItem(0, 0, 50, 50); ellipse->setPos(100, 100); scene->addItem(ellipse);This code creates a new QGraphicsEllipseItem object, sets its position to (100, 100), and adds it to the QGraphicsScene object called `scene`. In both examples, the `addItem` function is used to add the newly created QGraphicsItem objects to the scene.