AkiRoss
AkiRoss

Reputation: 12273

Moving children items in QGraphisItem

I have an item which is parent of some other items. It is not a group, in fact this item draws a cubic Bezier curve and the children are its control points.

The problem is that moving the children items will result in a geometry change, so I should call parent's prepareGeometryChange() when children are moved, but that method is protected.

This is just an example, and in general the question I'm seeking an answer is:

when a QGraphicsItem has a geometry that depends on its children, and the children are movable by user interaction, how do I use prepareGeometryChange()?

Is it necessary to call it? Is it wrong to build items in this way and use children for this purpose?

Upvotes: 1

Views: 410

Answers (1)

masoud
masoud

Reputation: 56519

I remember same issue for myself, I re-implemented

QGraphicsItem::itemChange(GraphicsItemChange change, const QVariant & value)

for both children and parent.

When each change was a QGraphicsItem::ItemPositionChange that child emits a signal, and the parent has a corresponding slot.

Upvotes: 1

Related Questions