macos installEventFilter QWebEngineView Invalid PlatformChannel receive right
-
from PySide6.QtWidgets import QMainWindow,QApplication,QVBoxLayout,QWidget from PySide6.QtCore import QObject,QUrl from PySide6.QtWebEngineWidgets import QWebEngineView import os,sys class MyEventFilter(QObject): def eventFilter(self, source, event): return super().eventFilter(source, event) class HeHe(QMainWindow): def __init__(self): super().__init__() self.event_filter = MyEventFilter() QApplication.instance().installEventFilter(self.event_filter) # macos err self.browser = QWebEngineView() self.browser.setUrl(QUrl('https://www.google.com')) central_widget = QWidget() layout = QVBoxLayout(central_widget) layout.addWidget(self.browser) central_widget.setLayout(layout) self.setCentralWidget(central_widget) if __name__ == "__main__": os.environ['QTWEBENGINE_DICTIONARIES_PATH'] = '/usr/local/bin/hunspell' app = QApplication(sys.argv) widget = HeHe() widget.show() sys.exit(app.exec())macos 12.7.5,inter core,pyside6 v6.7.2,python3.12,poetry
-
from PySide6.QtWidgets import QMainWindow,QApplication,QVBoxLayout,QWidget from PySide6.QtCore import QObject,QUrl from PySide6.QtWebEngineWidgets import QWebEngineView import os,sys class MyEventFilter(QObject): def eventFilter(self, source, event): return super().eventFilter(source, event) class HeHe(QMainWindow): def __init__(self): super().__init__() self.event_filter = MyEventFilter() QApplication.instance().installEventFilter(self.event_filter) # macos err self.browser = QWebEngineView() self.browser.setUrl(QUrl('https://www.google.com')) central_widget = QWidget() layout = QVBoxLayout(central_widget) layout.addWidget(self.browser) central_widget.setLayout(layout) self.setCentralWidget(central_widget) if __name__ == "__main__": os.environ['QTWEBENGINE_DICTIONARIES_PATH'] = '/usr/local/bin/hunspell' app = QApplication(sys.argv) widget = HeHe() widget.show() sys.exit(app.exec())macos 12.7.5,inter core,pyside6 v6.7.2,python3.12,poetry
macos installEventFilter QWebEngineView Invalid PlatformChannel receive right
QApplication.instance().installEventFilter(self.event_filter) # macos errAt the time that
installEventFilter()statement is executed you have not even created or used any kind ofQWebEngineView(). I fail to see how Qt could issue an error message from that line mentioningQWebEngineView. -
是只要加上QApplication.instance().installEventFilter(self.event_filter),QWebEngineView()就会报错。如果注释#QApplication.instance().installEventFilter(self.event_filter),QWebEngineView()就正常
如果把QWebEngineView()提升到QApplication.instance().installEventFilter(self.event_filter)之上,也不会报错。我印象中,在e...f之后使用view,在windows好像不报错,我记得我昨天在虚拟机上试过。