import sys from os.path import abspath, dirname, join from PySide2.QtCore import QAbstractNativeEventFilter from PySide2.QtGui import QGuiApplication from PySide2.QtQml import QQmlApplicationEngine #from PyQt5.QtCore import QAbstractNativeEventFilter #from PyQt5.QtGui import QGuiApplication #from PyQt5.QtQml import QQmlApplicationEngine class WinEventFilter(QAbstractNativeEventFilter): def nativeEventFilter(self, eventType, message): print(eventType) return False, 0 if __name__ == '__main__': app = QGuiApplication(sys.argv) wef = WinEventFilter() app.installNativeEventFilter(wef) engine = QQmlApplicationEngine() qmlFile = join(dirname(__file__), 'view.qml') engine.load(abspath(qmlFile)) if not engine.rootObjects(): sys.exit(-1) sys.exit(app.exec_())