说明
开启鼠标悬停事件意味着当鼠标悬停在该item下时,可由hoverMoveEvent()函数接收到鼠标的移动事件。开启方法: setAcceptHoverEvents(true)。
函数
- void QGraphicsItem::setAcceptHoverEvents(bool enabled)
- virtual void QGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent * event)
释义
- 设置接受悬停事件。enabled设置为true,意味着接收悬停事件。否则不接受。
- 悬停移动事件。重新实现该函数,并且设置setAcceptHoverEvents(true)时,可接收悬停移动事件。通过函数event->pos()可获得鼠标在当前item中的坐标。
示例
略。