I create a pyqt5 window and add a QWebEngineView in it. This is the code I wrote in the init method of QMainWindow. Creating the object and connect its loadFinished signal to a method works fine, But the other two lines of code lead to error.
self.browser = QWebEngineView()
self.browser.loadFinished.connect(self.update_title)
self.browser.setUrl(QUrl(url))
self.verticalLayout.addWidget(self.browser)
The error that the code encounters is:
[13864:9100:0526/131403.948:FATAL:tsf_text_store.cc(52)] Failed to initialize CategoryMgr.
Interestingly, this error does not occur when I run the code in debug mode.
python 3.7
PyQt5 5.15.4
PyQt5-Qt5 5.15.2
PyQt5-sip 12.9.0
PyQt5-stubs 5.15.2.0
PyQtWebEngine 5.15.4
PyQtWebEngine-Qt5 5.15.2
Here is a minimal reproducible example:
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *
class WebGameWindow(QMainWindow):
def __init__(self, *args, **kwargs):
super(WebGameWindow, self).__init__(*args, **kwargs)
self.browser = QWebEngineView()
self.browser.setUrl(QUrl("http://google.com"))
self.browser.loadFinished.connect(self.update_title)
self.setCentralWidget(self.browser)
def update_title(self):
title = self.browser.page().title()
self.setWindowTitle("% s" % title)