QGraphicsItem doesn't receive mouse hover events

前端 未结 2 714
温柔的废话
温柔的废话 2021-01-17 08:18

I have a class derived from QGraphicsView, which contains QGraphicsItem-derived elements. I want these elements to change color whenever the mouse

2条回答
  •  情书的邮戳
    2021-01-17 08:39

    In my case, hover events wouldn't work if I overrode mouseMoveEvent in my implementation of the QGraphicsView class. I fixed this by adding a call to

    QGraphicsView::mouseMoveEvent(event);
    

    which propagated the event to the parent, which in turn sent it out to all the scene items.

提交回复
热议问题