On this page

AnimatedImage QML Type

Plays animations stored as a series of images. More...

Import Statement: import QtQuick
Inherits:

Image

Enumerations

Properties

Signals

Detailed Description

The AnimatedImage type extends the features of the Image type, providing a way to play animations stored as images containing a series of frames, such as those stored in GIF files.

Information about the current frame and total length of the animation can be obtained using the currentFrame and frameCount properties. You can start, pause and stop the animation by changing the values of the playing and paused properties.

The full list of supported formats can be determined with QMovie::supportedFormats().

The number of times the animation plays can be controlled using the loops property. By default, the animation loops indefinitely. The finished signal is emitted when the animation finishes playing the specified number of loops.

Example Usage

The following QML shows how to display an animated image and obtain information about its state, such as the current frame and total number of frames. The result is an animated image with a simple progress indicator underneath it.

Note: When animated images are cached, every frame of the animation will be cached.

Set cache to false if you are playing a long or large animation and you want to conserve memory.

If the image data comes from a sequential device (e.g. a socket), AnimatedImage can only loop if cache is set to true.


import QtQuick

Rectangle {
    width: animation.width; height: animation.height + 8

    AnimatedImage { id: animation; source: "animation.gif" }

    Rectangle {
        property int frames: animation.frameCount

        width: 4; height: 8
        x: (animation.width - width) * animation.currentFrame / frames
        y: animation.height
        color: "red"
    }
}

See also BorderImage and Image.

Enumeration Documentation

[since 6.12] FinishBehavior

This enum describes the behavior when the animation finishes on its own.

ConstantDescription
AnimatedImage.FinishAtInitialFrameWhen the animation finishes it returns to the initial frame. This is the default behavior.
AnimatedImage.FinishAtFinalFrameWhen the animation finishes it stays on the final frame.

This enumeration was introduced in Qt 6.12.

Property Documentation

currentFrame : int

frameCount : int [read-only]

currentFrame is the frame that is currently visible. By monitoring this property for changes, you can animate other items at the same time as the image.

frameCount is the number of frames in the animation. For some animation formats, frameCount is unknown and has a value of zero.

finishBehavior : enumeration [since 6.12]

This property holds the behavior when the animation finishes on its own. The default value is FinishBehavior.{FinishAtInitialFrame}.

This property was introduced in Qt 6.12.

See also FinishBehavior.

loops : int [since 6.12]

This property holds the number of times the animation will play.

After playing the animation this many times, the animation will automatically stop and the finished signal will be emitted.

If this is set to AnimatedImage.Infinite (the default), the animation will not stop playing on its own.

Setting loops to 0 means the animation will not play.

Negative values are invalid.

This property was introduced in Qt 6.12.

paused : bool

This property holds whether the animated image is paused.

By default, this property is false. Set it to true when you want to pause the animation.

playing : bool

This property holds whether the animated image is playing.

By default, this property is true, meaning that the animation will start playing immediately.

Note: this property is affected by changes to the actual playing state of AnimatedImage. If non-animated images are used, playing will need to be manually set to true in order to animate following images.

AnimatedImage {
    onStatusChanged: playing = (status == AnimatedImage.Ready)
}

source : url

This property holds the URL that refers to the source image.

AnimatedImage can handle any image format supported by Qt, loaded from any URL scheme supported by Qt. It is however not compatible with QQuickImageProvider.

sourceSize : size

This property holds the scaled width and height of the full-frame image.

Unlike the width and height properties, which scale the painting of the image, this property sets the maximum number of pixels stored for cached frames so that large animations do not use more memory than necessary.

If the original size is larger than sourceSize, the image is scaled down.

The natural size of the image can be restored by setting this property to undefined.

Note: Changing this property dynamically causes the image source to be reloaded, potentially even from the network, if it is not in the disk cache.

See also Image::sourceSize.

speed : real [since QtQuick 2.11]

This property holds the speed of the animation.

The speed is measured in percentage of the original animated image speed. The default speed is 1.0 (original speed).

This property was introduced in QtQuick 2.11.

Signal Documentation

[since 6.12] finished()

This signal is emitted when the animation has finished playing the number of times specified by loops.

It is not emitted when playing is set to false manually, nor for animations whose loops property is set to AnimatedImage.Infinite.

Note: The corresponding handler is onFinished.

This signal was introduced in Qt 6.12.

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