QMovie Class▲
-
Header: QMovie
-
CMake:
find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
-
qmake: QT += gui
-
Inherits: https://
Detailed Description▲
This class is used to show simple animations without sound.
First, create a https:// object by passing either the name of a file or a pointer to a https:// containing an animated image format to https://'s constructor. You can call https://() to check if the image data is valid, before starting the movie. To start the movie, call https://(). https:// will enter https:// state, and emit https://() and https://(). To get the current state of the movie, call https://().
To display the movie in your application, you can pass your https:// object to QLabel::setMovie(). Example:
QLabel label;
QMovie *movie = new QMovie("animations/fire.gif");
label.setMovie(movie);
movie->start();Whenever a new frame is available in the movie, https:// will emit https://(). If the size of the frame changes, https://() is emitted. You can call https://() or https://() to get a copy of the current frame. When the movie is done, https:// emits https://(). If any error occurs during playback (i.e, the image file is corrupt), https:// will emit https://().
You can control the speed of the movie playback by calling https://(), which takes the percentage of the original speed as an argument. Pause the movie by calling https://(true). https:// will then enter https:// state and emit https://(). If you call https://(false), https:// will reenter https:// state and start the movie again. To stop the movie, call https://().
Certain animation formats allow you to set the background color. You can call https://() to set the color, or https://() to retrieve the current background color.
https://() returns the sequence number of the current frame. The first frame in the animation has the sequence number 0. https://() returns the total number of frames in the animation, if the image format supports this. You can call https://() to get the number of times the movie should loop before finishing. https://() returns the number of milliseconds the current frame should be displayed.
https:// can be instructed to cache frames of an animation by calling https://().
Call https://() for a list of formats that https:// supports.
See Also▲
See also QLabel, https://, Movie Example
Member Type Documentation▲
enum QMovie::CacheMode▲
This enum describes the different cache modes of https://.
|
Constant |
Value |
Description |
|---|---|---|
|
https://::CacheNone |
0 |
No frames are cached (the default). |
|
https://::CacheAll |
1 |
All frames are cached. |
enum QMovie::MovieState▲
This enum describes the different states of https://.
|
Constant |
Value |
Description |
|---|---|---|
|
https://::NotRunning |
0 |
The movie is not running. This is https://'s initial state, and the state it enters after https://() has been called or the movie is finished. |
|
https://::Paused |
1 |
The movie is paused, and https:// stops emitting https://() or https://(). This state is entered after calling pause() or https://(true). The current frame number it kept, and the movie will continue with the next frame when unpause() or https://(false) is called. |
|
https://::Running |
2 |
The movie is running. |
Property Documentation▲
[bindable] cacheMode : CacheMode▲
This property supports https:// bindings.
This property holds the movie's cache mode
Caching frames can be useful when the underlying animation format handler that https:// relies on to decode the animation data does not support jumping to particular frames in the animation, or even "rewinding" the animation to the beginning (for looping). Furthermore, if the image data comes from a sequential device, it is not possible for the underlying animation handler to seek back to frames whose data has already been read (making looping altogether impossible).
To aid in such situations, a https:// object can be instructed to cache the frames, at the added memory cost of keeping the frames in memory for the lifetime of the object.
By default, this property is set to https://.
See Also▲
See also https://
[bindable] speed : int▲
This property supports https:// bindings.
This property holds the movie's speed
The speed is measured in percentage of the original movie speed. The default speed is 100%. Example:
QMovie movie("racecar.gif");
movie.setSpeed(200); // 2x speedMember Function Documentation▲
[explicit] QMovie::QMovie(QObject *parent = nullptr)▲
Constructs a https:// object, passing the parent object to https://'s constructor.
See Also▲
See also https://(), https://(), https://()
[explicit] QMovie::QMovie(QIODevice *device, const QByteArray &format = QByteArray(), QObject *parent = nullptr)▲
Constructs a https:// object. https:// will use read image data from device, which it assumes is open and readable. If format is not empty, https:// will use the image format format for decoding the image data. Otherwise, https:// will attempt to guess the format.
The parent object is passed to https://'s constructor.
[explicit] QMovie::QMovie(const QString &fileName, const QByteArray &format = QByteArray(), QObject *parent = nullptr)▲
Constructs a https:// object. https:// will use read image data from fileName. If format is not empty, https:// will use the image format format for decoding the image data. Otherwise, https:// will attempt to guess the format.
The parent object is passed to https://'s constructor.
[virtual] QMovie::~QMovie()▲
Destructs the https:// object.
QColor QMovie::backgroundColor() const▲
Returns the background color of the movie. If no background color has been assigned, an invalid https:// is returned.
See Also▲
See also https://()
int QMovie::currentFrameNumber() const▲
Returns the sequence number of the current frame. The number of the first frame in the movie is 0.
QImage QMovie::currentImage() const▲
QPixmap QMovie::currentPixmap() const▲
QIODevice *QMovie::device() const▲
Returns the device https:// reads image data from. If no device has currently been assigned, nullptr is returned.
See Also▲
See also https://(), https://()
void QMovie::error(QImageReader::ImageReaderError error)▲
This signal is emitted by https:// when the error error occurred during playback. https:// will stop the movie, and enter https:// state.
See Also▲
See also https://(), https://()
QString QMovie::fileName() const▲
Returns the name of the file that https:// reads image data from. If no file name has been assigned, or if the assigned device is not a file, an empty https:// is returned.
See Also▲
See also https://(), https://()
void QMovie::finished()▲
QByteArray QMovie::format() const▲
Returns the format that https:// uses when decoding image data. If no format has been assigned, an empty QByteArray() is returned.
See Also▲
See also https://()
void QMovie::frameChanged(int frameNumber)▲
This signal is emitted when the frame number has changed to frameNumber. You can call https://() or https://() to get a copy of the frame.
int QMovie::frameCount() const▲
Returns the number of frames in the movie.
Certain animation formats do not support this feature, in which case 0 is returned.
QRect QMovie::frameRect() const▲
Returns the rect of the last frame. If no frame has yet been updated, an invalid https:// is returned.
See Also▲
See also https://(), https://()
bool QMovie::isValid() const▲
Returns true if the movie is valid (e.g., the image data is readable and the image format is supported); otherwise returns false.
For information about why the movie is not valid, see https://().
bool QMovie::jumpToFrame(int frameNumber)▲
Jumps to frame number frameNumber. Returns true on success; otherwise returns false.
bool QMovie::jumpToNextFrame()▲
Jumps to the next frame. Returns true on success; otherwise returns false.
QImageReader::ImageReaderError QMovie::lastError() const▲
Returns the most recent error that occurred while attempting to read image data.
See Also▲
See also https://()
QString QMovie::lastErrorString() const▲
Returns a human-readable representation of the most recent error that occurred while attempting to read image data.
See Also▲
See also https://()
int QMovie::loopCount() const▲
Returns the number of times the movie will loop before it finishes. If the movie will only play once (no looping), loopCount returns 0. If the movie loops forever, loopCount returns -1.
Note that, if the image data comes from a sequential device (e.g. a socket), https:// can only loop the movie if the https:// is set to https://.
int QMovie::nextFrameDelay() const▲
Returns the number of milliseconds https:// will wait before updating the next frame in the animation.
void QMovie::resized(const QSize &size)▲
This signal is emitted when the current frame has been resized to size. This effect is sometimes used in animations as an alternative to replacing the frame. You can call https://() or https://() to get a copy of the updated frame.
QSize QMovie::scaledSize()▲
void QMovie::setBackgroundColor(const QColor &color)▲
For image formats that support it, this function sets the background color to color.
See Also▲
See also https://()
void QMovie::setDevice(QIODevice *device)▲
Sets the current device to device. https:// will read image data from this device when the movie is running.
See Also▲
See also https://(), https://()
void QMovie::setFileName(const QString &fileName)▲
Sets the name of the file that https:// reads image data from, to fileName.
See Also▲
See also https://(), https://(), https://()
void QMovie::setFormat(const QByteArray &format)▲
Sets the format that https:// will use when decoding image data, to format. By default, https:// will attempt to guess the format of the image data.
You can call https://() for the full list of formats https:// supports.
See Also▲
See also https://(), https://()
void QMovie::setPaused(bool paused)▲
If paused is true, https:// will enter https:// state and emit https://(Paused); otherwise it will enter https:// state and emit https://(Running).
See Also▲
See also https://()
void QMovie::setScaledSize(const QSize &size)▲
void QMovie::start()▲
Starts the movie. https:// will enter https:// state, and start emitting https://() and https://() as the movie progresses.
If https:// is in the https:// state, this function is equivalent to calling https://(false). If https:// is already in the https:// state, this function does nothing.
See Also▲
See also https://(), https://()
void QMovie::started()▲
This signal is emitted after https://() has been called, and https:// has entered https:// state.
QMovie::MovieState QMovie::state() const▲
void QMovie::stateChanged(QMovie::MovieState state)▲
This signal is emitted every time the state of the movie changes. The new state is specified by state.
See Also▲
See also https://()
void QMovie::stop()▲
Stops the movie. https:// enters https:// state, and stops emitting https://() and https://(). If https://() is called again, the movie will restart from the beginning.
If https:// is already in the https:// state, this function does nothing.
See Also▲
See also https://(), https://()
[static] QList<QByteArray> QMovie::supportedFormats()▲
void QMovie::updated(const QRect &rect)▲
This signal is emitted when the rect rect in the current frame has been updated. You can call https://() or https://() to get a copy of the updated frame.


