PDA

View Full Version : QGraphicsSvgItem changes position after parenting



dodgeit
11th October 2011, 14:57
Hi!
I'm showing some object stored in a svg file and everything works fine. The problem comes when i parent some objects. I parent some objects with
child.setParentItem(parent) and after that the child object moves from its original position. There is any way the child object not to move when i parent it?
Is it supposed the child object to take the transform from his parent? I want the objects to stay at the same positions they are on the svg file after parenting them. Any idea how to get it?
Any ideas are welcome!!!

wysota
11th October 2011, 18:32
There is any way the child object not to move when i parent it?
Recalculate the position. You can do that for example using QGraphicsItem::mapFromScene() (with "this" being the parent and the position being the result of QGraphicsItem::scenePos() before you reparent the item).

Is it supposed the child object to take the transform from his parent?
Yes, it is supposed to work this way.