Loads a vector image file and displays it in a Qt Quick scene. 更多...
| import 語句: |
import QtQuick.VectorImage
|
| Since: | Qt 6.8 |
| 繼承: |
(從 6.10 起)
(從 6.10 起)
(從 6.10 起)
(從 6.10 起)
The VectorImage can be used to load a vector image file and display this as an item in a Qt Quick scene.
目前支持
SVG
file format. In addition, Lottie support can be enabled by setting the
assumeTrustedSource
property to true and including the plugin from the
Qt Lottie Animation
module. This plugin is currently considered tech preview.
注意: This complements the approach of loading the vector image file through an 圖像 元素: 圖像 creates a raster version of the image at the requested size. VectorImage builds a Qt Quick scene that represents the image. This means the resulting item can be scaled and rotated without losing quality, and it will typically consume less memory than the rasterized version.
|
animations group |
|---|
|
animations.loops
:
int
|
|
animations.paused
:
bool
|
These properties can be used to control animations in the image, if it contains any.
The
paused
property can be set to true to temporarily pause all animations. When the property is reset to
false
, the animations will resume where they were. By default this property is
false
.
The
loops
property defines the number of times the animations in the document will repeat. By default this property is 1. Any animations that is set to loop indefinitely in the source image will be unaffected by this property. To make all animations in the document repeat indefinitely, the
loops
property can be set to
Animation.Infinite
.
These propertys were introduced in Qt 6.10.
|
assumeTrustedSource
:
bool
|
Setting this to true when loading trusted source files expands support for some features that may be unsafe in an uncontrolled setting. For SVG in particular, this maps to the AssumeTrustedSource option .
When this is set to true, VectorImage will also try to load the image using the Lottie format plugin if this is available. This plugin is currently considered tech preview. See Qt Lottie Animation for additional information.
默認情況下此特性為
false
.
此特性在 Qt 6.10 引入。
另請參閱 svgtoqml and lottietoqml.
|
fillMode : enumeration |
This property defines what happens if the width and height of the VectorImage differs from the implicit size of its contents.
| 常量 | 描述 |
|---|---|
VectorImage.NoResize
|
The contents are still rendered at the size provided by the input. |
VectorImage.Stretch
|
The contents are scaled to match the width and height of the
VectorImage
. (This is the default.)
|
VectorImage.PreserveAspectFit
|
The contents are scaled to fit inside the bounds of the
VectorImage
, while preserving aspect ratio. The actual bounding rect of the contents will sometimes be smaller than the
VectorImage
項。
|
VectorImage.PreserveAspectCrop
|
The contents are scaled to fill the
VectorImage
item, while preserving the aspect ratio. The actual bounds of the contents will sometimes be larger than the
VectorImage
項。
|
|
preferredRendererType : enumeration |
Requests a specific backend to use for rendering shapes in the
VectorImage
.
| 常量 | 描述 |
|---|---|
VectorImage.GeometryRenderer
|
Equivalent to Shape.GeometryRenderer. This backend flattens curves and triangulates the result. It will give aliased results unless multi-sampling is enabled, and curve flattening may be visible when the item is scaled. |
VectorImage.CurveRenderer
|
Equivalent to Shape.CurveRenderer. With this backend, curves are rendered on the GPU and anti-aliasing is built in. Will typically give better visual results, but at some extra cost to performance. |
默認為
VectorImage.GeometryRenderer
.
|
source : url |
This property holds the URL of the vector image file to load.
VectorImage
currently supports the
SVG
file format. In addition, Lottie support can be enabled by setting the
assumeTrustedSource
property to true and including the plugin from the
Qt Lottie Animation
module. This plugin is currently considered tech preview.