我希望,从文档中,这个片段
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
QGraphicsView *v = new QGraphicsView(new QGraphicsScene);
setCentralWidget(v);
QGraphicsRectItem *r1 = v->scene()->addRect(QRectF(100,100, 200,200), QPen(), QBrush(Qt::red));
QGraphicsRectItem *r2 = new QGraphicsRectItem(r1);
r2->setRect(QRectF(10,10, 50,50));
r2->setBrush(QBrush(Qt::blue));
}
会在红色矩形内绘制一个蓝色矩形,结果如下:
我错过了什么吗?