How to use the QGraphicsView's translate() function?

后端 未结 4 725
暖寄归人
暖寄归人 2021-01-11 14:07

here i have a scene and a associated view ,then i hava a position in the scene coordinates.I want to set the center of the viewport with the position.How can i do it? I try

4条回答
  •  离开以前
    2021-01-11 14:58

    You need to set the transformation anchor mode of the graphics view to NoAnchor.

    setTransformationAnchor(QGraphicsView::NoAnchor);
    

    This prevents the graphics view from undoing the translation as expected by the other anchor modes (AnchorViewCenter, AnchorUnderMouse).

提交回复
热议问题