0
votes

here is the situation: I have QGraphicsView, QGraphicsScene and QGraphicsItem. When I do not implement mouse events, I can drag items. But when I implement in the QGraphicsView

class MyView: public QGraphicsView {
...
protected:
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
    void mousePressEvent(QMouseEvent *event);
...
}

I can't drag items anymore.

Should I implement somehow Mouse events for the QGraphicsItem and translate them from the QGraphicsView?

Currently, in QGraphicsItem I don't have these methods and use defaults. Thank you.

1
You either implement the moving of QGraphicsItem yourself, or call super for mouseMoveEvent, mouseReleaseEvent and mousePressEvent to continue processing the events inside the QGraphicsScene.Daniele Pantaleone
Daniele, thank you. The calling super mouseMoveEvent works perfectly. Could you outline it as an answer so I can mark it?Alexander Lyapin

1 Answers

1
votes

You either implement the moving of QGraphicsItem yourself, or call super for mouseMoveEvent, mouseReleaseEvent and mousePressEvent to continue processing the events inside the QGraphicsScene.