在Qt中缩放图形

Nar*_*rek 1 c++ graphics qt zoom

我使用QGraphicsViewQGraphicsScene绘制图形.
如何组织放大和缩小(在放大滚动时应该出现并且在缩小滚动时应该消失)?

Val*_*itz 5

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
Run Code Online (Sandbox Code Playgroud)

如果场景符合视图大小,则滚动条将自动消失.

此致,Valentin