Graphics View: prepareGeometryChange and adding child items
The Qt documentation states that prepareGeometryChange() needs to be called if an item is being resized. Does that also apply when adding child items that change the size of the parent, or does the framework do that automatically when a child is added? I ask because I called prepareGeometryChange() on the parent before adding a child and the scene didn't draw correctly, whereas commenting out the function call resulted in correct scene rendering. Any advice on how to correctly use prepareGeometryChange() would be appreciated.
Re: Graphics View: prepareGeometryChange and adding child items
Hi,
You are adding your items to the scene or another item?
Re: Graphics View: prepareGeometryChange and adding child items
The new item is being added as a child of another item currently in the scene.
Re: Graphics View: prepareGeometryChange and adding child items
If the result of the parent items boundingRect() function depends on the child items' bounding rects, then you need to call prepareGeometryChange().
Re: Graphics View: prepareGeometryChange and adding child items
Thanks, that's what I needed to know.
Re: Graphics View: prepareGeometryChange and adding child items
prepareGeometryChange is not requiired while adding items.
It is required when you want to change the shape of the item.
Say, you are drawing a line on the scene on mouse move. So you will need to change the shape of line item. Hence you will need to call prepareGeometryChange before actually changing the path of the line item.