Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Events with QGraphicsItemGroup

In my application I want to use QGraphicsItemGroup for grouping items into one item.
I played with it a little and not sure using it because when I want to catch events, events are merged together but I want to handle specific event with specific child.
How can I achieve this?

like image 647
onurozcelik Avatar asked Jun 11 '10 08:06

onurozcelik


2 Answers

You need to call QGraphicsItemGroup::setHandlesChildEvents(false). This stops the QGraphicsItemGroup trying to handle the event, and lets the child QGraphicsItems handle them instead.

like image 124
Whatang Avatar answered Nov 20 '22 04:11

Whatang


I think that's the point of the QGraphicsItemGroup. Judging from the documentation, this is meant to simplify moving and transforming multiple items at once e.g. imagine the following case: a user draws a selection rectangle around several items in an application because he wants to move all of them. Perhaps what you want more is to create a hierarchy of items, e.g. have one parent item with several child items. This way you'll get the individual events for each item. This can be accomplished by calling QGraphicsItem::setParentItem();

like image 5
humbagumba Avatar answered Nov 20 '22 03:11

humbagumba