同步QGraphicView元素
我有两个 QGraphicView 对象(基于相同的派生类)。它们包含不同的场景,但一些(有时很多)项目是相同的。这些项目有共同的坐标。我在同一帧内交替显示其中一个或另一个。我这样做没有遇到任何困难。
在这两个图形视图中,我都添加了放大和缩小以及移动视口的可能性。我添加了一个按钮来选择要显示的显示视图。我遇到的问题是,到目前为止我无法确保常见项目(同样具有相同的坐标)保留在屏幕上的同一位置。
您对如何同步两个视图有一些建议吗?
我尝试使用变换矩阵来解决这个问题,并且缩放现在可以工作,但我仍然有一个翻译问题,我似乎无法摆脱的 !
I have two QGraphicView objects (based on the same derived class). They contain different scenes, but a few (sometimes many) items are the same. Such items have common coordinates. I alternatively display the one or the other, inside the same frame. I have had no trouble doing that.
In both graphic views, i have added the possibility to zoom in and out, and move the viewport around. I added a button to select the display view to be displayed. The problem i have is i have been unable so far to make sure that common items (again, with same coordinates) stay at the same place on the screen.
Do you have some advice on how to synchronize the two views ?
I have tried to solve this using transform matrices, and zoom now works, but i still have a translation issue i can't seem to get rid of !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
翻译问题可能是更改转换后两个视图没有集中到同一点。默认情况下,锚定模式是将场景的中心定位到变换更改后视图的中心。将 transformationAnchor 设置为
NoAnchor
可能会有所帮助。您还需要确保两个场景具有相同的 sceneRect。
The translation issue is probably the 2 views are not centered to the same point after changing the transformation. By default the anchoring mode is to position the center of the scene to the center of the view after transformation change. Setting transformationAnchor to
NoAnchor
may help.You also need to make sure the 2 scenes have the same sceneRect.