0
我想在QGraphicsScene中以垂直順序依次放置3個QFrame。 我試圖使用QHBoxLayout和QLayout,沒有任何東西,QGraphicsScene不接受QLayout。如何在QGraphicsScene中放置QFrame?
QFrame * top = new QFrame;
QFrame * middle = new QFrame;
QFrame * bottom = new QFrame;
top->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
middle->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
bottom->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
top->setLineWidth(1);
middle->setLineWidth(1);
bottom->setLineWidth(1);
top->setFixedWidth(400);
top->setFixedHeight(150);
middle->setFixedWidth(400);
middle->setFixedHeight(250);
bottom->setFixedWidth(400);
bottom->setFixedHeight(150);
scene = new QGraphicsScene;
scene->setSceneRect(0, 0, 400, 550);
scene->addWidget(top);
scene->addWidget(middle);
scene->addWidget(bottom);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setFixedSize(400, 550);
setScene(scene);
show();
我該怎麼做才能使它工作?