开发者

Calculate scene coordinates from QGraphicsLinearLayout

In my application I used custom objects which derive from QGraphicsWidget and I put them inside QGraphicsLinearLayout. But now I need to find scene co开发者_StackOverflow社区ordinates of each item. Is it possible? How?


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.


Use this method from QGraphicsItem which is a base of QGraphicsWidget:

myItem->scenePos()
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜