There are already threads about this, but the solution I could find does not work.
Solution:
writing QGraphicsView::MousePressEvent(event);
at the end of my MousePressEvent class in the QGraphicsView derived class.
Both do not work. The QGraphicsItem-class does not receive the mouse events.
This is my MousePressEvent in my QGraphicsView class:
void GraphWidget::mousePressEvent(QMouseEvent *event){
mousePressed = true;
if (event->button() == Qt::RightButton) // doesn't matter
{
rightMousePressed = true;
_panStartX = event->x();
_panStartY = event->y();
setCursor(Qt::ClosedHandCursor);
event->accept();
return;
}
// And I tried this: QGraphicsView::mousePressEvent(event);
}
This is my MousePressEvent in my QGraphicsItem class:
void Node::mousePressEvent(QGraphicsSceneMouseEvent *event){
mousePressed = true;
qDebug() << "mouse trigered!";
}
Any ideas, what I've forgotten?