LottieAnimation is used to load and render Lottie files exported from Adobe After Effects. Currently, only subset of the full Lottie specification is supported. Most notable deviations are:
Only Shape layer supported
Only integer frame-mode of a timeline supported (real frame numbers and time are rounded to the nearest integer)
Expressions are not supported
For the full list of devations, please see see the Limitations section.
Example Usage
The following example shows a simple usage of the LottieAnimation type
LottieAnimation {
loops: 2
quality: LottieAnimation.MediumQuality
source: "animation.json"
autoPlay: false
onStatusChanged: {
if (status === LottieAnimation.Ready) {
// any acvities needed before
// playing starts go here
gotoAndPlay(startFrame);
}
}
onFinished: {
console.log("Finished playing")
}
}
Rendering Performance
Internally, the rendered frame data is cached to improve performance. You can control the memory usage by setting the QLOTTIE_RENDER_CACHE_SIZE environment variable (default value is 2).
You can monitor the rendering performance by turning on two logging categories:
qt.lottieqt.lottie.render - Provides information how the animation is rendered
qt.lottieqt.lottie.render.thread - Provides information how the rendering process proceeds.
Specifically, you can monitor does the frame cache gets constantly full, or does the rendering process have to wait for frames to become ready. The first case implies that the animation is too complex, and the rendering cannot keep up the pace. Try making the animation simpler, or optimize the QML scene.
This property holds the frame rate value of the Lottie animation.
frameRate changes after the asset has been loaded. Changing the frame rate does not have effect before that, as the value defined in the asset overrides the value. To change the frame rate, you can write:
This property holds the number of loops the player will repeat. The value LottieAnimation.Infinite means that the the player repeats the animation continuously.
Speficies the rendering quality of the lottie player. If LowQuality is selected the rendering will happen into a frame buffer object, whereas with other options, the rendering will be done onto QImage (which in turn will be rendered on the screen).
Constant
Description
LottieAnimation.LowQuality
Antialiasing or a smooth pixmap transformation algorithm are not used
LottieAnimation.MediumQuality
Smooth pixmap transformation algorithm is used but no antialiasing (Default)
LottieAnimation.HighQuality
Antialiasing and a smooth pixmap tranformation algorithm are both used