PDA

View Full Version : mouseEvent reaches other GraphicsItem than clicked on



wyzryn
21st October 2015, 18:42
Here's my implementation of mousePressEvent:



void Node::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if(event->button()==Qt::RightButton){
Owner owner(id);
owner.exec();
}

if(event->button()==Qt::LeftButton){
if(color == Qt::blue) color = Qt::red;
else color = Qt::blue;
}
}


Owner inherits QInputDialog and Node inherits QGraphicsItem.

The problem is that when I click on the first item, everything is just fine. The item that was hit changes color and I make some input.
But when I click on any other item it doesn't change color. The first one does instead.

What could cause the trouble?