[Development] Why does QQuickImageProvider not support SVG images?

Shawn Rutledge Shawn.Rutledge at qt.io
Thu Mar 13 18:11:29 CET 2025


> On Mar 12, 2025, at 09:46, Schimkowitsch Robert <Robert.Schimkowitsch at andritz.com> wrote:
> 
> Hi,
>  I immediately jumped on the brand-new VectorImage, and quickly found, to my disappointment, that I cannot use it, because I am missing an important piece.
> How am I supposed to pass a memory-generated SVG via URL?
>  Normally, I would do that via QQuickImageProvider, but it seems someone forgot SVGs there.

FWIW QQuickImageProvider is for images: you can see from its API that it generates QImage or QPixmap or a texture.  VectorImage generates scalable scene-graph nodes (it gets the GPU to do the rasterization and preserves quality at any zoom level), so it wouldn’t make sense for it to work with QQuickImageProvider.  An Image can render an SVG, but then you really generate a fixed-size image: you can set sourceSize, and then the SVG has to be re-rendered on the CPU each time.  It’s less efficient.

But you are welcome to write up a bug to ask for some way of supplying an SVG to VectorImage from a memory buffer rather than a file.

If you are generating the SVG on the fly anyway, maybe it’s better to generate a QPainterPath rather than serializing to SVG and getting Qt to deserialize it right away?  Then https://codereview.qt-project.org/c/qt/qtdeclarative/+/576288 might help (but it’s private API).  And qtdeclarative/tests/manual/painterpathquickshape might be interesting for you.



More information about the Development mailing list