Vector Image Formats in Qt | Qt 6.12
Description: Details on Qt's support for vector image formats

- Qt 6.12
- All Overviews
- Graphics
- Vector Image Formats in Qt
- Qt 6.12.0 Reference Documentation

2D Graphics ◦ Internationalization

# Vector Image Formats in Qt

Qt supports many standard file formats for loading graphical data, allowing applications to import content produced in other tools.

This article focuses on vector images, and which considerations to take when producing vector graphics content for use in a Qt application.

Note: For general information on Qt's support for 2D graphics, see the 2D Graphics in Qt documentation.

## File Format: SVG

SVG files can be loaded in two different ways in Qt Quick: Either as a software-rasterized image using the Image component or using hardware-accelerated rendering with VectorImage (including converting the file ahead of time using svgtoqml.)

In addition, QSvgRenderer provides general access to the software rasterizer. QSvgWidget and QGraphicsSvgItem provide convenience APIs for integrating SVG content in Qt Widgets applications.

As a baseline, Qt supports the static features of the SVG 1.2 Tiny profile. A detailed list of the features supported by this profile is available in the SVG 1.2 Tiny specification.

In addition, certain extended features are supported.

Interactive features of SVG are not supported, but interaction can easily be implemented in either Qt Quick or Qt Widgets. Some specific animation types are also supported, using either the SMIL format or CSS keyframes.

Here follows a high-level list of supported and unsupported features to give an overview of what to expect. Unsupported features will be ignored as far as it is possible, so that SVG files that depend on unsupported features will still show, but they may have omissions or errors.

Transforms | Supported
Position | 👍
Scale | 👍
Rotation | 👍
Skew | 👍
Shapes | Supported
Ellipse/circle | 👍
Rectangle | 👍
Polylines and polygons | 👍
Bezier paths | 👍
Markers | 👍
Symbols | 👍
Shape renderable | Supported
Fill | 👍
Stroke | 👍
Linear gradient | 👍
Radial gradient | 👍
Conical gradient | 👍
Patterns | 👍
Gradient stroke | 👍
Stroke caps | 👍
Stroke joins | 👍
Stroke styles (dashed, etc.) | 👍
Cosmetic strokes | 👍
Text | Supported
Spans | 👍
Glyphs | 👍
Post-processing effects | Supported
Masks | 👍
feColorMatrix | 👍
feFlood | 👍
feOffset | 👍
feGaussianBlur | 👍
feMerge | 👍
Remaining filters | 🚫
CSS animations | Supported
Colors | 👍
Gradients | 👍
Opacity | 👍
Transforms | 👍
Offset-path | 👍
Motion paths | 👍
Easing curves | 👍
Remaining properties | 🚫
SMIL animations | Supported
animateTransform | 👍
animateColor | 👍
animate | 🚫
animateMotion | 🚫
set | 🚫
Other | Supported
Raster images | 👍
Use element | 👍
Switch element | 👍
Clip paths | 🚫
Multimedia | 🚫
Scripting | 🚫
Linking | 🚫

## File Format: Lottie

Similarly to SVG, there are different ways of loading files in the Lottie format in Qt.

The LottieAnimation type loads an image and displays it using a software rasterizer, much like QSvgRenderer does for SVG.

In addition, hardware accelerated rendering is possible using VectorImage and the lottietoqml tool.

In order to use Lottie files with VectorImage, the `vectorimageformats` plugin included with the Qt Lottie Animation module must be deployed together with the application. In addition, the assumeTrustedSource property of the VectorImage must be set to `true`. Detailed control of the animation playback is available in LottieVectorImageController.

The lottietoqml tool can be used to pre-convert Lottie source files to QML. An example of this can be found in the lottietoqml Example.

The following is a list of the high-level features supported by the LottieAnimation type (software rasterizer) and VectorImage (also including pre-converting files using lottietoqml.)

Transforms | Supported
Position | 👍
Scale | 👍
Rotation | 👍
Skew | 👍
Opacity | 👍
Anchor point | 👍
Auto orient | 👍
Shapes | Supported
Ellipse/circle | 👍
Rectangle | 👍
Rounded rectangle | 👍
Polystar | 👍
Bezier paths | 👍
Trimmed paths | 👍
Shape renderable | Supported
Fill | 👍
Stroke | 👍
Linear gradient | 👍
Radial gradient | 👍
Gradient stroke | 👍
Stroke caps | 👍
Stroke joins | 👍
Stroke styles (dashed, etc.) | 👍
Text | Supported
Fill | 👍
Stroke | 🚫
Fonts | 👍
Glyphs | 👍
Post-processing effects | Supported
Alpha mattes | 👍
Luminance mattes | 👍
Layer effects | 🚫
Merged paths | Supported
Add | 👍
Subtract | 🚫
Intersect | 🚫
Masks | Supported
Mask path | 👍
Union | 👍
Additional operations | 🚫
Animations | Supported
Colors | 👍
Gradients | 👍
Opacity | 👍
Transforms | 👍
Path interpolation | 👍
Trims | 👍
Markers | 🚫
Merged paths | 🚫
Remaining properties | 🚫
Easing curves | 👍
Time stretch | 👍
Time remap | 👍
Other | Supported
Raster images | 👍
Precomp layers | 👍
Expressions | 🚫

## File Format: Font Files as a Vector Image Format

In addition to conventional format for vector graphics, like SVG, it is also possible to utilize custom font files where vector graphics assets are stored as glyphs.

This has the advantage that simple illustrations can be inlined in text labels, with typographical properties similar to text. This, in turn, that can make the alignment of the images with text easier.

Using font files for this purpose can also be a convenient way to distribute large icon libraries, as well as providing themes that can be replaced at run-time.

However, font use in Qt is optimized for producing text, so there are some considerations when using icon fonts as an alternative to specialized vector image components like VectorImage.

First of all, color fonts will always be pre-rasterized at the specified pixel size. This means that applying transforms to such text items will cause scaling artifacts. For illustrations that require zooming for instance, using VectorImage is preferable.

Using the specialized components is also preferable for any animated vector image. While the variable font format extension makes morphing animations possible, this is not the use the font system in Qt is optimized for. Therefore, animating the variable axes of a font will be less efficient than using another vector image format.

So for animated and/or multi-color vector images, using a format such as SVG should typically be preferred. For single-color, static ones, using a font is an option with certain conveniences.

Note: See also the standard icon support in Qt Quick Controls.

2D Graphics ◦ Internationalization