我重新实现了hoverEnterEvent,但由于某种原因,它没有被调用:-(我的方法在这一点上非常简单:
void LinteItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event) {
qDebug("Mouse hovered");
QGraphicsItem::hoverEnterEvent(event);
}我已经在视图上设置了mouseTracking。我能够放置新的LinteItems使用mouseMove等,所以我知道跟踪工作。
我在构造函数中包含以下内容:
setFlags(QGraphicsItem::ItemIsSelectable |
QGraphicsItem::ItemIsMovable |
QGraphicsItem::ItemSendsGeometryChanges);
setAcceptHoverEvents(true);你知道为什么我没有收到事件吗?我使用的是Qt 5.5 btw
发布于 2015-09-21 02:17:46
例如,如果您的重写自定义QGraphicsView鼠标事件处理程序调用基类的原始处理程序,则它应该可以工作
void CustomGraphicsView::mouseMoveEvent(QMouseEvent *event)
{
// do something...
// send the event to graphics scene and items
QGraphicsView::mouseMoveEvent(event);
}https://stackoverflow.com/questions/32679201
复制相似问题