VectorImage QML Type
加载矢量图像文件并将其显示在Qt Quick 场景中。更多
Import Statement: | import QtQuick.VectorImage |
Since: | Qt 6.8 |
Inherits: |
属性
- animations
(since 6.10)
- animations.loops : int
(since 6.10)
- animations.paused : bool
(since 6.10)
- animations.loops : int
- assumeTrustedSource : bool
(since 6.10)
- fillMode : enumeration
- preferredRendererType : enumeration
- source : url
详细说明
VectorImage 可用于加载矢量图像文件,并将其显示为Qt Quick 场景中的一个项目。
它目前支持SVG
文件格式。此外,还可通过将assumeTrustedSource 属性设置为 true 并将插件从 Qt Lottie Animation模块中包含该插件。该插件目前处于技术预览阶段。
注: 这与通过Image 元素加载矢量图像文件的方法相辅相成:Image 按要求的尺寸创建图像的光栅版本。VectorImage 会创建一个代表图像的Qt Quick 场景。这意味着生成的项目可以缩放和旋转而不会降低质量,而且通常比光栅化版本消耗更少的内存。
属性文档
如果图像中包含动画,这些属性可用于控制图像中的动画。
paused
属性可设置为 true,以暂时停止所有动画。当该属性重置为false
时,动画将恢复原状。默认情况下,该属性为false
。
loops
属性定义了文档中动画的重复次数。默认情况下,此属性为 1。源图像中设置为无限循环的任何动画都不会受此属性影响。要使文档中的所有动画无限重复,可将loops
属性设为Animation.Infinite
。
此 QML 属性在 Qt 6.10 中引入。
assumeTrustedSource : bool |
在加载可信源文件时,将该属性设置为 true 可扩展对某些功能的支持,这些功能在不受控的设置下可能是不安全的。特别是对于 SVG,它映射到AssumeTrustedSource option 。
设置为 true 时,如果 Lottie 格式插件可用,VectorImage 还将尝试使用该插件加载图片。该插件目前处于技术预览阶段。请参见 Qt Lottie Animation了解更多信息。
默认情况下,此属性为false
。
此属性在 Qt 6.10 中引入。
另请参阅 svgtoqml和 lottietoqml。
fillMode : enumeration |
该属性定义了如果VectorImage 的宽度和高度不同于其内容的隐含大小时会发生的情况。
常量 | 说明 |
---|---|
VectorImage.NoResize | 内容仍按输入提供的尺寸渲染。 |
VectorImage.Stretch | 内容按比例缩放,以匹配VectorImage 的宽度和高度(这是默认值)。 |
VectorImage.PreserveAspectFit | 缩放内容以适应VectorImage 的边界,同时保持宽高比。内容的实际边界矩形有时会小于VectorImage 项目。 |
VectorImage.PreserveAspectCrop | 内容按比例填充VectorImage 项目,同时保持宽高比。内容的实际边界有时会大于VectorImage 项目。 |
preferredRendererType : enumeration |
请求使用特定的后端来渲染VectorImage
中的形状。
常量 | 描述 |
---|---|
VectorImage.GeometryRenderer | 等同于 Shape.GeometryRenderer。该后端会平整曲线并对结果进行三角化处理。除非启用多重取样功能,否则它将生成有别名的结果,并且在缩放项目时可能会看到曲线扁平化。 |
VectorImage.CurveRenderer | 等同于 Shape.CurveRenderer。使用此后端,曲线将在 GPU 上渲染,并内置抗锯齿功能。通常会带来更好的视觉效果,但会对性能造成一定的影响。 |
默认值为VectorImage.GeometryRenderer
。
source : url |
该属性包含要加载的矢量图像文件的 URL。
VectorImage 目前支持SVG
文件格式。此外,还可通过将assumeTrustedSource 属性设置为 true 并将插件从 Qt Lottie Animation模块中包含该插件。该插件目前为技术预览版。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.