Qt:当UI包含QWebEngineView时是否安装全局事件过滤器?

时间:2019-02-28 01:26:13

标签: qt pyside2 qwebengineview eventfilter

我正在尝试向我的应用程序安装全局事件过滤器。只要不使用QWebEngineView,eventfilter就能正常工作。

最小示例:

import sys

from PySide2 import QtCore, QtWidgets
from PySide2.QtWebEngineWidgets import QWebEngineView


class GlobalEventFilter(QtCore.QObject):
    def eventFilter(self, watched: QtCore.QObject, event: QtCore.QEvent):
        print(type(watched), event.type())
        return super().eventFilter(watched, event)


if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    global_filter = GlobalEventFilter()
    app.installEventFilter(global_filter)
    # window = QtWidgets.QTextEdit()  # works fine with any QWidget
    window = QWebEngineView()         # crashes: Received signal 11 SEGV_MAPERR
    window.show()
    sys.exit(app.exec_())

我该如何解决?

0 个答案:

没有答案