QWebEngineView fails loading SVG using setHtml(...)
<p>I tried two different ways to load and show an SVG file in PyQt:</p>

<pre><code>import sys
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl

app = QApplication(sys.argv)
webView = QWebEngineView()

# Variant 1: Reasonably fast
webView.load(QUrl('file:///Test.svg'))

# Variant 2: Slow for small files, not working for big ones
webView.setHtml('&lt;svg&gt;........')

webView.show()
sys.exit(app.exec_())
</code></pre>

<p>The first way works okay but requires a file as input. I would like to generate the SVGs dynamically though, so this is not really an option. Does anyone have an idea why the second approach is so darn slow or failing completely for more complex vector images?</p>

<p>The <code>setHtml</code> function cannot load any content (not just svg) that is greater than 2MB in size. This is because Chromium uses a <code>data:</code> scheme url to load the content (which obvioulsy limits the size to the maximum length for a url). So it would seem that the only option is to load the svg from a local file.</p>

<ul>
<li>See: <a href="http://bugreports.qt.io/browse/QTBUG-53414" rel="nofollow">QTBUG-53414</a></li>
</ul>

python qt svg pyqt5 qtwebengine