python - PyQT 标签的鼠标悬停事件过滤器

标签 python pyqt mouseover

我一直在尝试转换示例 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 返回 TrueFalse,以表明您是否已完全处理该事件。

关于python - PyQT 标签的鼠标悬停事件过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3858449/

相关文章:

python - 列出所有可能总和达到某个值的列表

c# - 如何在 pythonnet winforms 字体中使用自定义构造函数?

python - 如何不在 QHBoxLayout 中分隔小部件

javascript - 如何清除以 setInterval 启动的计时器?

jquery - 忽略 Mouseover 元素的子元素中的 Mouseout 事件

python Pandas : How to combine or merge two difrent size dataframes based on dates

'Distance Sensor' 和 'Relay' Raspberry Pi 的 Python 代码

python - 在 PyQt 中绘制具有高程和降低效果的 3D 矩形/多边形

python - 使用 QStandardItemModel 获取 QListView 中选定的索引

macos - Cocoa osx NSButton 当鼠标悬停时显示文本