QMovie 类是用于播放电影的方便类,采用 QImageReader . 更多...
继承 QObject .
QMovie 类是用于播放电影的方便类,采用 QImageReader .
This class is used to show simple animations without sound. If you want to display video and media content, use the Phonon multimedia framework instead.
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 运行 state, and emit started () 和 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 ()。范例:
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 () 是 emitted. You can call currentImage () 或 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 运行 state and start the movie again. To stop the movie, call stop ().
Certain animation formats allow you to set the background color. 可以调用 setBackgroundColor () to set the color, or backgroundColor () 以检索 current background color.
currentFrameNumber () 返回 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 ().
调用 supportedFormats () for a list of formats that QMovie supports.
此枚举描述不同缓存模式,为 QMovie .
| 常量 | 值 | 描述 |
|---|---|---|
| QMovie.CacheNone | 0 | 没有帧被缓存 (默认)。 |
| QMovie.CacheAll | 1 | 所有帧都被缓存。 |
此枚举描述不同状态为 QMovie .
| 常量 | 值 | 描述 |
|---|---|---|
| QMovie.NotRunning | 0 | The movie is not running. This is QMovie 's initial state, and the state it enters after stop () has been called or the movie is finished. |
| QMovie.Paused | 1 | The movie is paused, and QMovie stops emitting updated () 或 resized (). This state is entered after calling pause () or setPaused(true). The current frame number it kept, and the movie will continue with the next frame when unpause () 或 setPaused(false) is called. |
| QMovie.Running | 2 | The movie is running. |
parent argument, if not None, causes self to be owned by Qt instead of PyQt.
构造 QMovie object, passing the parent object to QObject 's 构造函数。
另请参阅 setFileName (), setDevice (),和 setFormat ().
parent argument, if not None, causes self to be owned by Qt instead of PyQt.
构造 QMovie 对象。 QMovie will use read image data from device , which it assumes is open and readable. If format is not empty, QMovie will use the image format format for decoding the image data. Otherwise, QMovie will attempt to guess the format.
parent 对象被传递给 QObject 的构造函数。
parent argument, if not None, causes self to be owned by Qt instead of PyQt.
构造 QMovie 对象。 QMovie will use read image data from fileName 。若 format is not empty, QMovie will use the image format format for decoding the image data. Otherwise, QMovie will attempt to guess the format.
parent 对象被传递给 QObject 的构造函数。
Returns the background color of the movie. If no background color has been assigned, an invalid QColor 被返回。
另请参阅 setBackgroundColor ().
Returns the sequence number of the current frame. The number of the first frame in the movie is 0.
返回当前帧,作为 QImage .
另请参阅 currentPixmap () 和 updated ().
返回当前帧,作为 QPixmap .
另请参阅 currentImage () 和 updated ().
Returns the device QMovie reads image data from. If no device has currently been assigned, 0 is returned.
另请参阅 setDevice () and fileName ().
Returns the name of the file that QMovie reads image data from. If no file name has been assigned, or if the assigned device is not a file, an empty QString 被返回。
另请参阅 setFileName () 和 device ().
Returns the format that QMovie 使用 when decoding image data. If no format has been assigned, an empty QByteArray() is returned.
另请参阅 setFormat ().
Returns the number of frames in the movie.
Certain animation formats do not support this feature, in which case 0 is returned.
Returns the rect of the last frame. If no frame has yet been updated, an invalid QRect 被返回。
另请参阅 currentImage () 和 currentPixmap ().
Returns true if the movie is valid (e.g., the image data is readable and the image format is supported); otherwise returns false.
Jumps to frame number frameNumber . Returns true on success; otherwise returns false.
This method is also a Qt slot with the C++ signature bool jumpToNextFrame() .
Jumps to the next frame. Returns true on success; otherwise returns false.
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), QMovie can only loop the movie if the cacheMode is 设为 QMovie.CacheAll .
Returns the number of milliseconds QMovie will wait before updating the next frame in the animation.
Returns the scaled size of frames.
该函数在 Qt 4.1 引入。
另请参阅 setScaledSize () 和 QImageReader.scaledSize ().
For image formats that support it, this function sets the background color to color .
另请参阅 backgroundColor ().
把当前设备设为 device . QMovie will read image data from this device when the movie is running.
另请参阅 device () 和 setFormat ().
Sets the name of the file that QMovie reads image data from, to fileName .
另请参阅 fileName (), setDevice (),和 setFormat ().
Sets the format that QMovie will use when decoding image data, to format . By default, QMovie will attempt to guess the format of the image data.
可以调用 supportedFormats () for the full list of formats QMovie 支持。
另请参阅 format () 和 QImageReader.supportedImageFormats ().
This method is also a Qt slot with the C++ signature void setPaused(bool) .
若 paused is true, QMovie will enter Paused state and emit stateChanged(Paused); otherwise it will enter 运行 state and emit stateChanged(Running).
Sets the scaled frame size to size .
该函数在 Qt 4.1 引入。
另请参阅 scaledSize () 和 QImageReader.setScaledSize ().
This method is also a Qt slot with the C++ signature void start() .
Starts the movie. QMovie 将进入 运行 state, and start emitting updated () 和 resized () as the movie progresses.
若 QMovie is in the Paused state, this function is equivalent to calling setPaused(false). If QMovie is already in the 运行 state, this function does nothing.
返回当前状态,为 QMovie .
另请参阅 MovieState and stateChanged ().
This method is also a Qt slot with the C++ signature void stop() .
停止电影。 QMovie 进入 NotRunning state, and stops emitting updated () 和 resized ()。若 start () is called again, the movie will restart from the beginning.
若 QMovie is already in the NotRunning state, this function does nothing.
Returns the list of image formats supported by QMovie .
该函数在 Qt 4.1 引入。
另请参阅 QImageReader.supportedImageFormats ().
This is the default overload of this signal.
此信号被发射由 QMovie when the error error occurred during playback. QMovie will stop the movie, and enter QMovie.NotRunning 状态。
This is the default overload of this signal.
This signal is emitted when the movie has finished.
另请参阅 QMovie.stop ().
This is the default overload of this signal.
This signal is emitted when the frame number has changed to frameNumber . You can call currentImage () 或 currentPixmap () to get a copy of the frame.
该函数在 Qt 4.1 引入。
This is the default overload of this signal.
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 currentImage () 或 currentPixmap () to get a copy of the updated frame.
This is the default overload of this signal.
此信号被发射在 QMovie.start () has been called, and QMovie has entered QMovie.Running 状态。
This is the default overload of this signal.
This signal is emitted every time the state of the movie changes. The new state is specified by state .
另请参阅 QMovie.state ().
This is the default overload of this signal.
This signal is emitted when the rect rect in the current frame has been updated. You can call currentImage () 或 currentPixmap () to get a copy of the updated frame.