本页面

Qt Lottie Animation

Qt Lottie Animation 提供了用于渲染 Lottie 格式文件中图形和动画的 QML API。这些文件通常由 Adobe After Effects 的Lottie插件导出。

LottieAnimation 组件使用QPainter软件渲染器将动画渲染到中间缓冲区中。这可能会对插图的大小以及目标硬件造成一定的性能限制。 作为替代方案,本项目包含了一个名为lottietoqml的工具。该工具可将 Lottie 动画转换为 QML。因此,这些动画可以使用Qt Quick 中的硬件加速渲染器进行渲染。

如果编译时已知 Lottie 文件,您也可以使用lottietoqml工具,或封装该工具的qt_target_qml_from_lottieCMake 命令,将其转换为 QML。

最后,VectorImage Qt Quick 组件可直接加载 Lottie 格式的文件。它会在运行时利用插件中的lottietoqml功能将这些文件转换为 QML。

入门指南

使用以下语句导入类型:

import Qt.labs.lottieqt

限制

该实现遵循Lottie 的主规范。当发现导出的 Lottie 文件与规范存在差异时,我们会尽可能予以考虑。

一般限制

  • 不支持表达式
  • 时间轴仅支持帧模式,不支持时间模式

警告: Qt Lottie Animation 的输入文件被视为可信内容。建议应用程序开发人员切勿传递来自不可信来源的数据。

动画层级限制

不支持以下属性:

  • assets - 可重用的文本和图像
  • chars 文本

图层

不支持以下属性:

  • bm (混合模式)

形状

某些较少使用的元素和形状不被支持,包括:

  • 嵌套的重复图形

另请注意,使用多个活动修剪路径(例如嵌套组中的修剪路径)时,其行为难以预测。

效果

目前仅支持以下效果:Slide 和Layer Fill 。

示例

许可

Qt Lottie Animation 可通过The Qt Company 获取商业许可。此外,它还遵循GNU 通用公共许可证第 3 版。更多详细信息请参阅Qt 许可。

参考

© 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.