[Development] Why does QQuickImageProvider not support SVG images?

Schimkowitsch Robert Robert.Schimkowitsch at andritz.com
Fri Mar 14 09:33:00 CET 2025


Hi Shawn,

> FWIW QQuickImageProvider is for images: you can see from its API that it
> generates QImage or QPixmap or a texture.

I would argue that an SVG IS an image, see e.g. the definition from Wikipedia:
" A representation of the form of a person or object[...]"
So why should QQuickImageProvider not have a 'requestSvg'  function (naturally without size parameter)?

> 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.

I do that currently and cache the pixmaps in their correct size. It's fine for most use cases, but small SVGs become really ugly when rendered with QSvgRenderer. I was hoping for better quality using VectorImage.

>
> 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.

Done in the meantime, see https://bugreports.qt.io/browse/QTBUG-134656 and https://bugreports.qt.io/browse/QTBUG-134666

>
> 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?

My use case is this: I take existing (potentially customer-provided) SVGs and modify them on the fly (colorization to match my current color scheme).
I know there is a mechanism to convert SVGs to QML files, this may be an alternative to look at, but it is a lot more complex to integrate.

Kind regards

Robert

________________________________

This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.

ANDRITZ HYDRO GmbH


Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation

Firmensitz/ Registered seat: Wien

Firmenbuchgericht/ Court of registry: Handelsgericht Wien

Firmenbuchnummer/ Company registration: FN 61833 g

DVR: 0605077

UID-Nr.: ATU14756806


Thank You
________________________________


More information about the Development mailing list