开发者

General advice about scaling on QGraphicsView/QGraphicsScene

In my project I am using QGraphicsView/Q开发者_JS百科GraphicsScene stuff.

On my scene there will be regions that contains 2D graphics. Region count will be limited(Lets say 20)

Users can choose to display one or more regions.

If user choose to display one region I am going to show one region on scene

If user choose to display n regions I am going to show n regions on scene

I need a scaling logic to fit n regions on same scene.

How can I achieve this?


QGraphicsView::fitInView() should do what you want:

QRectF bounding;
foreach(QRectF r, selectedRegionRects) {
    bounding |= r;
}
scene->fitInView(bounding, Qt::KeepAspectRatio);


I believe you should use ensureVisible method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜