views:

24

answers:

1

Hi.

I have an application where a QGraphicsPolygonItem (objectA) has the following characteristics:

ScenePos: X=250 Y=125

Transform():

|----|---|---|
| 2  | 0 | 0 |
| 0  | 1 | 0 |
| 50 | 0 | 1 |
|----|---|---|

Now, I am creating and new QGraphicsPolygonItem (objectB) and setting its scenepos and Transform the same as object A:

objectB = new QGraphicsPolygonItem();
objectB->setPolygon(objectA->polygon());
objectB->setScenePos(objectA->ScenePos);
objectB->setTransform(objectA->transform);

The problem is that objectB moves 50 units away from ObjectA in the X axis.

Any idea why?

A: 

This happens because scenePos() retrives the absolute position of the object in the scene without taking into consideration its transformation matrix. It work with the use of pos().

Carlos.

QLands