PDA

View Full Version : Graphics View: prepareGeometryChange and adding child items



abernat
16th February 2009, 17:51
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.

zgulser
16th February 2009, 18:13
Hi,

You are adding your items to the scene or another item?

abernat
16th February 2009, 18:21
The new item is being added as a child of another item currently in the scene.

spud
16th February 2009, 18:52
If the result of the parent items boundingRect() function depends on the child items' bounding rects, then you need to call prepareGeometryChange().

abernat
16th February 2009, 18:53
Thanks, that's what I needed to know.

aamer4yu
17th February 2009, 05:35
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.