I have a QGraphicsScene that contains a hierarchy of QGraphicsItems. Method item.scenePos() returns the scene coordinates of the item. I'm looking for something like setScenePos() in order to change positions of the items by giving them scene coordinates. How can I achieve this ?
1 Answers
1
votes
As the docs says:
QPointF QGraphicsItem::scenePos() const
Returns the item's position in scene coordinates. This is equivalent to calling mapToScene(0, 0).
to get what you want you can do the inverse
# setScenePos(QPointF point)
point = QPointF(xx, yy)
point_item = item.mapFromScene(point)
item.setPos(point_item)