LottieVectorImageController QML Type
为正在显示 Lottie 文件的 `VectorImage ` 提供动画控制功能。更多内容...
| Import Statement: | import Qt.labs.lottieqt 1.0 |
| Since: | Qt 6.12 |
| Inherits: |
属性
- currentFrame : real
- endFrame : real
- frameRate : real
- startFrame : real
- target : VectorImage
方法
- void gotoAndPlay(real frame)
- void gotoAndStop(real frame)
- void pause()
- void play()
- void start()
- void stop()
- void togglePause()
详细说明
VectorImage 可以显示和播放 Lottie 动画,但仅凭它本身,提供的播放控制功能还比较基础。LottieVectorImageController 继承自VectorImage ,并提供了更强大的 API 来查询和控制动画。
LottieVectorImageController 的target 属性指定了待控制的VectorImage 。 如果 LottieVectorImageController 是作为VectorImage 的子元素或属性创建的,则该属性默认已设置。当VectorImage 加载了 Lottie 文件,且其status 为Ready 时,即可读取和写入 LottieVectorImageController 的属性,并调用其函数来控制播放。
结合VectorImage 使用时,LottieVectorImageController模拟了现有LottieAnimation 控件的API,因此通常只需稍作调整即可互换使用。(getDuration() 函数未提供,因为它可通过使用endFrame 、startFrame 以及可选的frameRate 属性构建的简单表达式轻松替代。)
另请参阅 VectorImage 以及qtlottieviewer 示例。
属性文档
currentFrame : real [read-only]
当前显示的动画帧编号。
endFrame : real [read-only]
源文件中指定的动画结束帧号(“out-frame”)。
frameRate : real
该属性用于存储动画的播放速度(单位为帧/秒)。
加载矢量图像时,该属性将设置为源文件中指定的帧率值。
加载完成后,可以修改 frameRate 来改变播放速度。将其赋值为空将重置为源文件中的值。
startFrame : real [read-only]
源文件中指定的动画起始帧号(“in-frame”)。
target : VectorImage
此属性指定要控制的VectorImage 。
如果该LottieVectorImageController 是作为VectorImage 的子对象或属性创建的,则该 将成为默认目标。否则,必须显式设置目标。
方法文档
void gotoAndPlay(real frame)
将播放位置移至 Lottie 帧号frame 并开始播放。
frame 该值将在startFrame 和endFrame 之间进行限制。
void gotoAndStop(real frame)
将播放进度移至 Lottie 帧号frame 并暂停播放。
frame 该值将在startFrame 和endFrame 之间进行限制。
void pause()
暂停播放。
void play()
开始(恢复)播放。
void start()
从startFrame 处重新开始播放。
void stop()
将播放重置为startFrame ,并暂停播放。
void togglePause()
在播放和暂停模式之间切换target VectorImage 。
© 2026 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.