eventFilter on a QWidget with PyQt4

瘦欲@ 提交于 2019-12-01 09:51:05
ekhumoro

Firstly, the event filter needs to be set by the object you want to watch:

points.installEventFilter(self)

Secondly, the event you need to listen for is MouseMove not HoverMove:

if event.type() == QtCore.QEvent.MouseMove:

Finally, you need to enable mouse-tracking on the target widget:

class DrawingPointsWidget(QWidget):
    def __init__(self):
        super(QWidget, self).__init__()
        self.setMouseTracking(True)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!