![]() |
Home · Overviews · Examples |
The QMovie class is a convenience class for playing movies with QImageReader. More...
Inherits QObject.
The QMovie class is a convenience class for playing movies with QImageReader.
First, create a QMovie object by passing either the name of a file or a pointer to a QIODevice containing an animated image format to QMovie's constructor. You can call isValid to check if the image data is valid, before starting the movie. To start the movie, call start. QMovie will enter Running state, and emit started and stateChanged. To get the current state of the movie, call state.
To display the movie in your application, you can pass your QMovie 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, QMovie will emit updated. If the size of the frame changes, resized is emitted. You can call currentImage or currentPixmap to get a copy of the current frame. When the movie is done, QMovie emits finished. If any error occurs during playback (i.e, the image file is corrupt), QMovie will emit error.
You can control the speed of the movie playback by calling setSpeed, which takes the percentage of the original speed as an argument. Pause the movie by calling setPaused(true). QMovie will then enter Paused state and emit stateChanged. If you call setPaused(false), QMovie will reenter Running state and start the movie again. To stop the movie, call stop.
Certain animation formats allow you to set the background color. You can call setBackgroundColor to set the color, or backgroundColor to retrieve the current background color.
currentFrameNumber returns the sequence number of the current frame. The first frame in the animation has the sequence number 0. frameCount returns the total number of frames in the animation, if the image format supports this. You can call loopCount to get the number of times the movie should loop before finishing. nextFrameDelay returns the number of milliseconds the current frame should be displayed.
QMovie can be instructed to cache frames of an animation by calling setCacheMode.
Call supportedFormats for a list of formats that QMovie supports.
See also QLabel, QImageReader, and Movie Example.
Copyright © 2007 Trolltech | Trademarks | Qt Jambi 4.3.2_01 |