views:

20

answers:

1

I wonder if it is possible to select item that belongs to one group, without selecting whole group.

What I trying to make is a group of items, that can be moved (all items are moved together) but none of them can't be moved individually. But I want also to be able to select items inside this group and then do something with them, like reordering, deleting, changing their color, etc.

The other problem is, there can be group of groups. I wish also to be able to select these groups inside parent group. I was thinking that this could be problem, because we are not able to determine which group users want to select. For demonstration purpose, lets say that we have graphic's scene composed of following items:

Group A which contains group B. The group B contains 3 lines. If I press double click on group A, then I am then able to select group B. If I again press double click on B, then I am able to select lines inside group B. Pressing Esc does opposite as double click. The problem is, I have no idea how to do that, because all selection is routed to the parents, and than back to all its children.

A: 

You can't use QGraphicsItemGroup to do this because selecting one item in a group automaticaly selects all other memebrs of the group.

I'd subclass QGraphicsItem to create a 'RootItem' class. This class would contain two lists. One is a list of ordinary QGraphicsItems that make up the visual elements of the group itself, parented to this RootItem. The other list is of other RootItems that are parented to this one (e.g. Group B).

You would just need to make sure that you carefully controlled which items are selectable at any one time and how the interactions propagate between items.

Hope this helps.

Simon Hibbs