我一直在尝试转换示例 here使用简单的标签。
代码如下:
class mouseoverEvent(QtCore.QObject):
def __init__(self, parent):
super(mouseoverEvent, self).__init__(parent)
def eventFilter(self, object, event):
if event.type() == QtCore.QEvent.MouseMove:
print "mousemove!"
self.filter = mouseoverEvent(self)
self.label.installEventFilter(self.filter)
现在奇怪的是,这确实有效,但不是没有我的控制台被“mousemove!”垃圾邮件(好)以及错误:TypeError: invalid result type from mouseoverEvent.eventFilter()
我还没有完全弄清楚事件之间的复杂关系,所以这对我来说有点古怪。那么,给出了什么?
提前致谢。
最佳答案
我认为您需要从 eventFilter 返回 True
或 False
,以表明您是否已完全处理该事件。
关于python - PyQT 标签的鼠标悬停事件过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3858449/