PDA

View Full Version : QGraphicsItem goes out of scene



pratham_shah
3rd July 2013, 12:10
Hi,

I have a 2 custom QGraphicsItem say MainGraphicsItem and AttachedGraphicsItem.
MainGraphicsItem has many children of type AttachedGraphicsItem (MainGraphicsItem is the parent AttachedGraphicsItem)
All these items are in a scene (the scene expands automatically).

Consider MainGraphicsItem as a rectangle and AttachedGraphicsItem as a small circle. They are arranged as shown in the attached image.
9264

Now when I move MainGraphicsItem to the right edge of the scene the AttachedGraphicsItem go out of the scene and are not visible. (Please see pic 2)
9265
The scene doesn't expand in this case.

Can you please resolve the issue.

wysota
3rd July 2013, 12:47
Why do you say the scene doesn't expand? Since scroll bars appear it seems that it does.

pratham_shah
3rd July 2013, 13:10
Sorry for creating the misunderstanding. What I meant was, the scene expands when the MainGraphicsItem goes out of the scene, but it doesn't when AttachedGraphicsItem go out of the scene. As seen in the second image some AttachedGraphicsItem are cut (out of scene). The scroll bars have been completely scrolled to right.

wysota
3rd July 2013, 13:22
Are those small items children of the bigger item?

pratham_shah
3rd July 2013, 15:06
Yes ..
Small Items (AttachedGraphicsItem) are children of Big Item (MainGraphicsItem).
MainGraphicsItem can have multiple children of type AttachedGraphicsItem.

wysota
3rd July 2013, 16:44
I think the scene has no direct way of tracking items that are not directly its own children. You might have to react to position change of the main item and make the scene grow yourself.