• 9372阅读
  • 2回复

QGraphicsView的平移问题 [复制链接]

上一主题 下一主题
离线wisconxing
 
只看楼主 倒序阅读 楼主  发表于: 2008-10-22
— 本帖被 XChinux 从 General Qt Programming 移动到本区(2011-01-02) —
我创建了一个QGraphicsView类视图view,在view内有一个场景view(&scene);  场景中有一map图元:scene.addItem(map);  我用视图view的rotate()函数可以旋转显示map,但为什么不能用视图view的translate平移map呢?
离线chaoscxm
只看该作者 1楼 发表于: 2008-10-22
public final void translate(double dx,
                            double dy)Translates the current item transformation by (dx, dy).
If all you want is to move an item, you should call moveBy() or setPos() instead; this function changes the item's translation, which is conceptually separate from its position.

这个函数只是把原点设为你要的点,并没有移动物体,注意,并非原点一定就在左上角。换句话说,移动的是坐标轴,而不是物体。用moveBy() or setPos() 来移动物体
帖子签名(将在每个帖子下方显示)
离线wisconxing
只看该作者 2楼 发表于: 2008-10-23
谢谢 chaoscxm 。
可能是我问的不清楚,我已在scene场景里画了一个背景图,然后又往场景里addItem了许多目标图元。最后在QGraphicsView里显示场景。我现在想在QGraphicsView里平移显示scene里的背景图和目标图元。请问用什么办法可以实现?
快速回复
限100 字节
 
上一个 下一个