lundi 20 avril 2015

graphicsview receives mouse event before the item

I have implemented the panning view on the QGraphicsView, using the mouse move event using

void View::mouseMoveEvent(QMouseEvent* event) {
pan();
QGraphicsView::mouseMoveEvent(event);
}

and in the scene of this view I have added few items where some of the items are resizable, so I implemented

void Item::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
 if(m_resizeMode)
    {
      resize();
      e->accept();
    }
}

I tried to filter the mouse move not to propagate to any further using e->accept() but my View mouseMove event has been called first , so when ever I tried to resize the item, the view started to pan all the way.

How can I avoid this event propagation from view to scene.

Aucun commentaire:

Enregistrer un commentaire