The simplest is to use QTextEdit:
html="""
<p>This is an image:</p>
<p><img src="file:Markups-copy-paste.png" width="100"></p>
<p>Another image:</p>
<p><img src="file:ClippingFanMask.png" width="100"></p>
<p>And some more text.</p>
"""
resourceFolder = "c:/tmp/20211221/"
resourceFiles = [
"Markups-copy-paste.png",
"ClippingFanMask.png"
]
textEdit = qt.QTextEdit()
textEdit.readOnly=True
textEdit.setHtml(html)
textDocument = textEdit.document
for resourceFile in resourceFiles:
resourceFilePath = resourceFolder+resourceFile
uri = qt.QUrl().fromLocalFile(resourceFile)
image = qt.QImage()
image.load(resourceFilePath)
textDocument.addResource(qt.QTextDocument.ImageResource, uri, image)
textEdit.show()
For rendering complex tables, videos, using dynamic content (Javascript), etc. you can use the heavyweight slicer.qSlicerWebWidget()
, which is a thin wrapper over QWebEngineView.