当QWebEngineView开始加载网页时,我想向其注入a web page progress bar,如下所示,但我在加载过程中看不到进度条,这是怎么回事?
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *
from PyQt5.QtWebEngineCore import *
from PyQt5.QtCore import *
class WebEngineView(QWebEngineView):
def __init__(self, parent=None):
super().__init__(parent)
self.webPage = self.page()
self.webPage.runJavaScript('''
var script = document.createElement('script');
var link = document.createElement('link');
script.type = 'text/javascript';
script.src = 'static/pace/pace.min.js';
link.rel = 'stylesheet';
link.href = 'static/pace/pace-theme-barber-shop.css';
document.head.appendChild(script);
document.head.appendChild(link);
''')
self.webPage.load(QUrl('https://doc.qt.io/qt-5/qwebenginepage.html'))
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setAttribute(Qt.AA_UseSoftwareOpenGL)
webEngineView = WebEngineView()
webEngineView.show()
sys.exit(app.exec_())