Baris Atamer
Baris Atamer

Reputation: 720

Child QGraphicsItem move event (ItemIsMovable) to its parent

How can a child QGraphicsItem move its parent item ?

I set the child item's ItemIsMovable flag and when I try to move the child item, the parent item does not move, only child item moves.


// child items's mouseMoveEvent
void TextDiagram::mouseMoveEvent(QGraphicsSceneMouseEvent *event){
     parentItem()->moveBy(event->pos().x() - lastPos.x() , event->pos().y() -lastPos.y() );
     QGraphicsItem::mouseMoveEvent(event);
}

void TextDiagram::mousePressEvent(QGraphicsSceneMouseEvent *event){ lastPos.setX( event->pos().x() ); lastPos.setY( event->pos().y() ); QGraphicsItem::mousePressEvent(event); }

This works but if I select more than one item, it only moves the item under the mouse.

How can I solve this ?

Upvotes: 1

Views: 2301

Answers (1)

Baris Atamer
Baris Atamer

Reputation: 720

I solved this by invoking parent's mouse events in child's mouse events .

Upvotes: 2

Related Questions