PDA

View Full Version : QGraphicsView ignore mouseMoveEvent triggered by QGraphicsItem



Casper14
22nd July 2014, 21:36
I have a simple problem that I cannot figure out how to solve. I have a QGraphicsView that has a few QGraphicsItems inside of it. When the user clicks and drags inside the QGraphicsView it scrolls the image. I need to intercept this event, and so I implemented


void
MyQGraphicsView::
mouseMoveEvent(QMouseEvent *event) {
if (event->buttons() == Qt::LeftButton) {
std::cout << "mouse move event\n";
}
QGraphicsView::mouseMoveEvent(event);
}

This part works fine. However, when the user clicks and drags one of the QGraphicsItems, this event is also triggered. I do not want this - I want the mouseMoveEvent in the QGraphicsView only to trigger if the mouse was dragged when not on a QGraphicsItem. Any suggestions?