Isn't there a more elegant solution?
My actual implementation looks like this:
qreal x = event->pos().x();
qreal y = event->pos().y();
if ( x <= boundingRect().x()
x >= boundingRect().right()
y <= boundingRect().y()
y >= pos.y() >= boundingRect().bottom() ){
doSomething();
}
}
void ParentClass::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) {
qreal x = event->pos().x();
qreal y = event->pos().y();
if ( x <= boundingRect().x()
x >= boundingRect().right()
y <= boundingRect().y()
y >= pos.y() >= boundingRect().bottom() ){
doSomething();
}
}
To copy to clipboard, switch view to plain text mode
An alternative to the preceding should be like this:
if ( !boundingRect().contains( tmpPos ) )
doSomething()
}
void ParentClass::hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) {
QPointF tmpPos = event->pos();
if ( !boundingRect().contains( tmpPos ) )
doSomething()
}
To copy to clipboard, switch view to plain text mode
but the result isn't the same... anyone can explain me why????
Bookmarks