在 Qt 中缩放图形

发布于 2024-09-10 18:15:54 字数 84 浏览 2 评论 0原文

我使用 QGraphicsView 和 QGraphicsScene 来绘制图形。
如何组织放大和缩小(放大时滚动条应出现,缩小时滚动条应消失)?

I use QGraphicsView and QGraphicsScene in order to draw graphics.
How can I organize zoom-in and zoom-out (during zooming in scrolls should appear and while zooming out scrolls should disappear)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

却一份温柔 2024-09-17 18:15:54
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

如果场景适合视图大小,滚动条将自动消失。

问候,
瓦伦丁

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

Scroll-bars will disappear automatically if scene fits into the size of view.

Regards,
Valentin

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文