I am trying to figure out how objects in a QGraphics Scene/View can be manipulated and redrawn.
From what I have learnt so far, when a QGraphicsItem needs to be added to the scene,
1. The object is derived from QGraphicsItem.
2. boundingRect(), and paint() needs to be reimplemented.
3. If some of the sizes need to be changed, use prepareGeometry(), and update().
So, I am working with two actions. One to add a box to the scene, and the other to increase the size when selected.
I tried to get it to work in one application and it did not work.(diagram.zip). The sizes of the item seem to reset before painting. I can see this if I keep increasing the size and trap the code. However, under certain paths it seem to work. For example, if I add a child to a box and select the parent, the size of the parent can be changed programmatically.
However, I created the minimum code required and it worked.
The code is in GrScene.zip
Why is there a difference in behavior?
Thanks in advance.
Bookmarks