PyQt QtWebChannel: calling Python function from JavaScript
问题 I am trying, using Qt classes QWebEngineView , and QWebChannel to make a simple connection between HTML page and Python script. The goal is simply to execute foo() when the header <h2> is clicked. import sys from PyQt5.QtCore import pyqtSlot from PyQt5.QtWidgets import QApplication from PyQt5.QtWebChannel import QWebChannel from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage html = ''' <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <script src="qrc:///qtwebchannel