我使用QGraphicsView
和QGraphicsScene
来绘制图形。如何组织放大和缩小(在放大时应显示滚动,而在缩小时应消失)?
最佳答案
QGraphicsView::scale(qreal, qreal)
e.g.
QGraphicsView * view = new QGraphicsView (parent);
QGraphicsScene *scene = new QGraphicsScene();
scene->addText("Hello World");
view->setScene(scene);
view->show();
view->resize(100,100);
// coll from some slot to see the effect
view->scale(2,2); //zoom in
view->scale(.5,.5); //zoom out
如果场景适合 View 大小,滚动条将自动消失。
问候,
瓦伦丁