2
votes

I'm creating an application with Qt. I'm using a QGraphicsView with a QGraphicsScene. I am sub-classing QGraphicsView because I need to add custom mouse event functionality. My issue is that, when I re-implement the mouse event functions, original QGraphicsView functionality doesn't work.

i.e. I re-implemented some mouse press and release events, and now I can't drag the QGraphicsScene, even though I have

this->setDragMode(QGraphicsView::ScrollHandDrag);

Hopefully my issue is clear enough, if not please let me know what is unclear.

1

1 Answers

5
votes

Are you calling the base class implementations for the mouse event handlers you're overriding? For example,

void MyGraphicsView::mousePressEvent(QMouseEvent *e)
{
    // Custom logic

    QGraphicsView::mousePressEvent(e);
}