开发者

Calculate scene coordinates from QGraphicsLinearLayout

开发者 https://www.devze.com 2023-02-06 03:06 出处:网络
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

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

精彩评论

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

关注公众号