0

在我的应用程序中,我使用了从 QGraphicsWidget 派生的自定义对象,并将它们放在 QGraphicsLinearLayout 中。但现在我需要找到每个项目的场景坐标。可能吗?如何?

4

2 回答 2

0

QGraphicsWidget inherits from QGraphicsObject which in turn inherits from QGraphicsItem. So you can use one of the mapToScene function to convert item coordinates to the scene ones.

For example:

QPointF p = myItem->mapToScene(QPointF(0,0));

will give you the scene location of the top left corner of the item.

于 2011-01-21T12:55:34.943 回答
0

使用 QGraphicsItem 中的这个方法,它是 QGraphicsWidget 的基础:

myItem->scenePos()
于 2020-06-15T09:25:13.340 回答