QWebEngineView 加载url,显示页面内容要10多秒(用浏览器打开很快的),我试了加载本地web和百度url,打开也就不到5s。如何优化QWebEngineView 加载url的速度?
class MyApp(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_body()
# 通过py文件引入
self.ui.setupUi(self)
self.view = MainWindow()
self.Layout = QHBoxLayout(self.ui.centralwidget)
self.Layout.setContentsMargins(0, 0, 0, 0)
# tab里嵌套页面
self.Layout.addWidget(self.view)
#
# 全屏展示
self.showMaximized()
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.view = QWebEngineView()
self.channel = QWebChannel()
self.python_object = PythonToJS(self.view) # 保存为成员变量
self.channel.registerObject("python_object", self.python_object)
self.view.page().setWebChannel(self.channel)
# # #
# curdir = os.getcwd()
# url = os.path.join(curdir, 'qtweb.html')
# self.view.load(QUrl.fromLocalFile(url))
self.view.load(QUrl("https://fof.cnhbstock.com/hbec-amt/#/home"))
# self.view.setStyleSheet("*{ font-family: '微软雅黑' }")
self.setCentralWidget(self.view)