开发者

Synchronize QGraphicView elements

I have two QGraphicView objects (based on the same derived class). Th开发者_如何学Pythoney 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 !


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜