QGraphics 场景放大和缩小
在这里我再次担心如何在图形场景中放大和缩小 QGraphicsPixmapItem。我为此寻找了直接方法,但在图形场景或像素图中找不到任何方法。有人可以帮我解决这个问题吗?我是否必须扩展 QGraphicsPixmapItem 并为此实现方法。
再次感谢您的帮助,我真的很感激。
〜塔兰加
Here I am again worrying about how to Zoom in and out a QGraphicsPixmapItem in a graphics scene. I looked for a direct method for this but could not find any in graphics scene or in pix map. Can someone help me with this. Do I have to extend QGraphicsPixmapItem and implement methods for this.
Thanks again for help and I really do appreciate it.
~Tharanga
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
setScale() 更改项目的大小,而不是场景的视图比例。对于单项场景来说,它实际上是相同的。但是,如果场景中有多个项目,则会改变项目之间的关系。
如果满足以下条件,则应使用
QGraphicsView::setTransform()
您想要保持该项目与场景和其他项目的关系。setScale() changes the size of the item, not the view scale of the scene. For a one item scene, it's effectively the same. But if you have more than one item in the scene, it changes the relation between items.
QGraphicsView::setTransform()
should be used if you want to keep the item's relationship to the scene and other items.QGraphicsPixmapItem
继承自QGraphicsItem
,因此它具有该类的所有方法。特别是,
setScale
将会改变项目的比例因子(即“缩放”它)。请参阅转换示例页面,了解如何完成此操作以及其他转换你可以做的。
QGraphicsPixmapItem
inherits fromQGraphicsItem
, so it has all of that class's methods.In particular, there's
setScale
that will change the item's scale factor (i.e. "zoom" it).Look at the Transformations Example page for how this is done, and other transformations you can do.