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 ?
I solved this by invoking parent's mouse events in child's mouse events .