Hi,
i'm using QGraphicsItem and some animations, i have a problem when i change the parent of an item because also it's position is changed. That's due to the fact that the position is related to the parent position, so i tried this:
item->setPos(item->mapToItem(new_parent, item->pos());
item->setParentItem(new_parent);
but it seams like setParentItem occurs before setPos() and it updates the scene with the item in the wrong position.
The only solution i found is to block all scene signals, set the parent , set the position, unlock the signals and update:
QPointF position = item->pos();
scene()->blocksignals(true);
item->setPos(item->mapToItem(new_parent, item->pos());
item->setParentItem(new_parent);
scene()->blocksignals(false);
that does the job but i'm looking for something more elegant than block all signals, also because i have other items on the scene and that would block their signal as well.
Any suggestion?!?
Thanks.
Bookmarks