我有两个不同的类继承QGraphicsItem
. 两者都有其特定的mousePressEvent
功能。当这些项目在场景中重叠时,我只想执行其中一项mousePressEvent
。我怎样才能做到这一点?
void PpiTargetItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
mTargetColor = Qt::red;
event->setAccepted(true);
}
// Bigger Item
void CriticalRegion::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
LOGGER_START
mCorners[0] = new CornerGrabber(this, 0);
mCorners[1] = new CornerGrabber(this, 1);
mCorners[2] = new CornerGrabber(this, 2);
mCorners[3] = new CornerGrabber(this, 3);
mCorners[0]->installSceneEventFilter(this);
mCorners[1]->installSceneEventFilter(this);
mCorners[2]->installSceneEventFilter(this);
mCorners[3]->installSceneEventFilter(this);
setCornerPositions();
event->setAccepted(true);
LOGGER_END
}