- Qt 6.11
- Qt Quick
- qt_target_qml_from_svg
- Qt 6.11.0 Reference Documentation

# qt_target_qml_from_svg

Generates QML code based on an SVG file.

The command is defined in the `QuickTools` component of the `Qt6` package, which can be loaded like this:

     find_package(Qt6 REQUIRED COMPONENTS QuickTools)

This command was introduced in Qt 6.11.

## Synopsis

     qt_target_qml_from_svg(target
                            [CURVE_RENDERER]
                            [OPTIMIZE_PATHS]
                            [OUTLINE_STROKE_MODE]
                            [TYPE_NAME "MyShapeName"]
                            [COPYRIGHT_STATEMENT "Copyright © Company1"]
                            FILES file1.svg [file2.svg ...]
                            OUTPUTS File1.qml [File2.qml ...]
                            )

If versionless commands are disabled, use `qt6_target_qml_from_svg()` instead. It supports the same set of arguments as this command.

Example:

     qt_target_qml_from_svg(vectorimageexample
         CURVE_RENDERER
         OPTIMIZE_PATHS
         FILES heart.svg
         OUTPUTS Heart.qml
         COPYRIGHT_STATEMENT
             "Copyright © 2024 The Qt Company Ltd.\\nSPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause"
     )

## Description

qt_target_qml_from_svg() creates the build steps to run svgtoqml on the list of SVG images in `FILES`. The names of the generated files should be specified in `OUTPUTS`. The length of this list must be the same as `FILES`, and the first element corresponds to the first element in `FILES` and so forth. The names provided in `OUTPUTS` will be the names of the QML types as they appear in the module. These can in turn be instantiated in the application code.

The generated QML files will be added to the QML module of `target`. You must use qt_add_qml_module() to define a module for the `target` first.

Optionally, a `COPYRIGHT_STATEMENT` argument can be provided to insert copyright information into the generated files.

Note: Certain characters must be escaped for command line use or you may see build errors on some platforms.

`TYPE_NAME` is also optional, and can be used to replace all instances of the Shape type in the generated file with a custom type. This can be useful to make general customizations to all the shapes in the provided SVG files. The `TYPE_NAME` should refer to a QML type which is available in the `target` QML module.

The options `CURVE_RENDERER`, `OPTIMIZE_PATHS` and `OUTLINE_STROKE_MODE` correspond to the `--curve-renderer`, `--optimize-paths` and `--outline-stroke-mode` in svgtoqml respectively.