Update a QGraphicsItem bounding rectangle after a transformation
I'm using setRotation() on a QGraphicsPolygonItem and I would like to get the bounding rectangle after the rotation using boundingRect(), but it doesn't change with the transformation.
I tried using prepareGeometryChange() in a subclass of QGraphicsPolygonItem but I can't get it work, I probably made a mistake since I'm new to this kind of things.
Can someone explain me how to use prepareGeometryChange(), or tell me any other way to update the bounding rectangle after the rotation ?
Does someone have any idea about this?
I've come across the same problem.
Thanks in advance
From the docs:
"the bounding rect is always rectangular, and it is unaffected by the items' transformation."
The bounding rect is given in item coordinate space, therefore it does not change when you rotate the item. If e.g. you want the bounding rect of an item as seen in scene coordinates, you need to map it, e.g. using
The output of this mapping will change when you rotate the item.