Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. macos installEventFilter QWebEngineView Invalid PlatformChannel receive right
Qt 6.11 is out! See what's new in the release blog

macos installEventFilter QWebEngineView Invalid PlatformChannel receive right

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 2 Posters 458 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    roland-cn
    wrote on last edited by roland-cn
    #1
    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

    JonBJ 1 Reply Last reply
    0
    • R roland-cn
      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

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @roland-cn

      macos installEventFilter QWebEngineView Invalid PlatformChannel receive right

      QApplication.instance().installEventFilter(self.event_filter) # macos err

      At the time that installEventFilter() statement is executed you have not even created or used any kind of QWebEngineView(). I fail to see how Qt could issue an error message from that line mentioning QWebEngineView.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        roland-cn
        wrote on last edited by roland-cn
        #3

        是只要加上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好像不报错,我记得我昨天在虚拟机上试过。

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved