派生要素QGraphicsView
を含むから派生したクラスがあります。QGraphicsItem
これらの要素の上にマウス カーソルが置かれるたびに色が変わるようにしたいので、hoverEnterEvent
(およびhoverLeaveEvent
)を実装しました。
void MyGraphicsItem::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
{
update (boundingRect());
}
ただし、このイベント ハンドラー コードは実行されません。マウス トラッキングを明示的に有効にしました。
MyGraphicsView::MyGraphicsView(MainView *parent) :
QGraphicsView(parent)
{
setMouseTracking(true);
viewport()->setMouseTracking(true);
...
}
それでも、運が悪い。私は何を間違っていますか?