Do *not* use setHtml as you are loading xhtml which is a different specification with very different parsing rules that are much less forgiving than the html spaghetti.
Use:
void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl())
The baseURL is the path to the file as a QUrl, and data holds the contents of the file in bytes (ie. a bytes buffer that you read the entire file into), and of course the proper mimetype: = "application/xhtml+xml"
See the QtWebEngineView online docs:
https://doc.qt.io/qt-6/qwebengineview.html
And for a python example see the calibre source code here:
https://github.com/kovidgoyal/calibr...lay/webview.py
Code:
if force_as_html or load_as_html(html):
view.setHtml(html, loading_url)
else:
view.setContent(QByteArray(html.encode(codec)), mime_type,
loading_url)
mf = view.page().mainFrame()
elem = mf.findFirstElement('parsererror')