Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtGui More...
#include <qmovie.h>
Public Types | |
enum | MovieState { NotRunning , Paused , Running } |
This enum describes the different states of QMovie. More... | |
enum | CacheMode { CacheNone , CacheAll } |
This enum describes the different cache modes of QMovie. More... | |
Public Slots | |
void | start () |
Starts the movie. | |
bool | jumpToNextFrame () |
Jumps to the next frame. | |
void | setPaused (bool paused) |
If paused is true, QMovie will enter \l Paused state and emit stateChanged(Paused); otherwise it will enter \l Running state and emit stateChanged(Running). | |
void | stop () |
Stops the movie. | |
void | setSpeed (int percentSpeed) |
Public Slots inherited from QObject | |
void | deleteLater () |
\threadsafe | |
Signals | |
void | started () |
This signal is emitted after QMovie::start() has been called, and QMovie has entered QMovie::Running state. | |
void | resized (const QSize &size) |
This signal is emitted when the current frame has been resized to size. | |
void | updated (const QRect &rect) |
This signal is emitted when the rect rect in the current frame has been updated. | |
void | stateChanged (QMovie::MovieState state) |
This signal is emitted every time the state of the movie changes. | |
void | error (QImageReader::ImageReaderError error) |
This signal is emitted by QMovie when the error error occurred during playback. | |
void | finished () |
This signal is emitted when the movie has finished. | |
void | frameChanged (int frameNumber) |
This signal is emitted when the frame number has changed to frameNumber. | |
Signals inherited from QObject | |
void | destroyed (QObject *=nullptr) |
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked. | |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
This signal is emitted after the object's name has been changed. | |
Public Member Functions | |
QMovie (QObject *parent=nullptr) | |
Constructs a QMovie object, passing the parent object to QObject's constructor. | |
QMovie (QIODevice *device, const QByteArray &format=QByteArray(), QObject *parent=nullptr) | |
Constructs a QMovie object. | |
QMovie (const QString &fileName, const QByteArray &format=QByteArray(), QObject *parent=nullptr) | |
Constructs a QMovie object. | |
~QMovie () | |
Destructs the QMovie object. | |
void | setDevice (QIODevice *device) |
Sets the current device to device. | |
QIODevice * | device () const |
Returns the device QMovie reads image data from. | |
void | setFileName (const QString &fileName) |
Sets the name of the file that QMovie reads image data from, to fileName. | |
QString | fileName () const |
Returns the name of the file that QMovie reads image data from. | |
void | setFormat (const QByteArray &format) |
Sets the format that QMovie will use when decoding image data, to format. | |
QByteArray | format () const |
Returns the format that QMovie uses when decoding image data. | |
void | setBackgroundColor (const QColor &color) |
For image formats that support it, this function sets the background color to color. | |
QColor | backgroundColor () const |
Returns the background color of the movie. | |
MovieState | state () const |
Returns the current state of QMovie. | |
QRect | frameRect () const |
Returns the rect of the last frame. | |
QImage | currentImage () const |
Returns the current frame as a QImage. | |
QPixmap | currentPixmap () const |
Returns the current frame as a QPixmap. | |
bool | 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 . | |
QImageReader::ImageReaderError | lastError () const |
Returns the most recent error that occurred while attempting to read image data. | |
QString | lastErrorString () const |
Returns a human-readable representation of the most recent error that occurred while attempting to read image data. | |
bool | jumpToFrame (int frameNumber) |
Jumps to frame number frameNumber. | |
int | loopCount () const |
Returns the number of times the movie will loop before it finishes. | |
int | frameCount () const |
Returns the number of frames in the movie. | |
int | nextFrameDelay () const |
Returns the number of milliseconds QMovie will wait before updating the next frame in the animation. | |
int | currentFrameNumber () const |
Returns the sequence number of the current frame. | |
int | speed () const |
QBindable< int > | bindableSpeed () |
QSize | scaledSize () |
Returns the scaled size of frames. | |
void | setScaledSize (const QSize &size) |
Sets the scaled frame size to size. | |
CacheMode | cacheMode () const |
void | setCacheMode (CacheMode mode) |
QBindable< CacheMode > | bindableCacheMode () |
Public Member Functions inherited from QObject | |
Q_INVOKABLE | QObject (QObject *parent=nullptr) |
Constructs an object with parent object parent. | |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. | |
virtual bool | event (QEvent *event) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. | |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
Filters events if this object has been installed as an event filter for the watched object. | |
QString | objectName () const |
Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
Sets the object's name to name. | |
void | setObjectName (QAnyStringView name) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QBindable< QString > | bindableObjectName () |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false . | |
bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false . | |
bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false . | |
bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false . | |
bool | blockSignals (bool b) noexcept |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
QThread * | thread () const |
Returns the thread in which the object lives. | |
bool | moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL) |
Changes the thread affinity for this object and its children and returns true on success. | |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
int | startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
void | killTimer (Qt::TimerId id) |
template<typename T > | |
T | findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
template<typename T > | |
QList< T > | findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. | |
template<typename T > | |
T | findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename T > | |
QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const QObjectList & | children () const |
Returns a list of child objects. | |
void | setParent (QObject *parent) |
Makes the object a child of parent. | |
void | installEventFilter (QObject *filterObj) |
Installs an event filter filterObj on this object. | |
void | removeEventFilter (QObject *obj) |
Removes an event filter object obj from this object. | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const |
bool | disconnect (const QObject *receiver, const char *member=nullptr) const |
void | dumpObjectTree () const |
Dumps a tree of children to the debug output. | |
void | dumpObjectInfo () const |
Dumps information about signal connections, etc. | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. | |
bool | setProperty (const char *name, QVariant &&value) |
QVariant | property (const char *name) const |
Returns the value of the object's name property. | |
QList< QByteArray > | dynamicPropertyNames () const |
QBindingStorage * | bindingStorage () |
const QBindingStorage * | bindingStorage () const |
QObject * | parent () const |
Returns a pointer to the parent object. | |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false . | |
Static Public Member Functions | |
static QList< QByteArray > | supportedFormats () |
Returns the list of image formats supported by QMovie. | |
Static Public Member Functions inherited from QObject | |
static QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
\threadsafe | |
static QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
\threadsafe | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static bool | disconnect (const QMetaObject::Connection &) |
Disconnect a connection. | |
template<typename Func1 , typename Func2 > | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot) |
template<typename Func1 > | |
static bool | disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero) |
Properties | |
int | speed |
the movie's speed | |
CacheMode | cacheMode |
the movie's cache mode | |
Properties inherited from QObject | |
QString | objectName |
the name of this object | |
Additional Inherited Members | |
Protected Member Functions inherited from QObject | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. | |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
This event handler can be reimplemented in a subclass to receive timer events for the object. | |
virtual void | childEvent (QChildEvent *event) |
This event handler can be reimplemented in a subclass to receive child events. | |
virtual void | customEvent (QEvent *event) |
This event handler can be reimplemented in a subclass to receive custom events. | |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
Protected Attributes inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Related Symbols inherited from QObject | |
template< class T > T | qobject_cast (const QObject *object) |
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QObjectList | |
\macro Q_CLASSINFO(Name, Value) | |
\inmodule QtGui
The QMovie class is a convenience class for playing movies with QImageReader.
This class is used to show simple animations without sound.
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 \l 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:
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 \l Paused state and emit stateChanged(). If you call setPaused(false), QMovie will reenter \l 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.
enum QMovie::CacheMode |
enum QMovie::MovieState |
This enum describes the different states of QMovie.
\value NotRunning 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.
\value Paused The movie is paused, and QMovie stops emitting updated() or 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() or setPaused(false) is called.
\value Running The movie is running.
Enumerator | |
---|---|
NotRunning | |
Paused | |
Running |
Constructs a QMovie object, passing the parent object to QObject's constructor.
Definition at line 572 of file qmovie.cpp.
|
explicit |
Constructs a QMovie object.
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.
The parent object is passed to QObject's constructor.
Definition at line 588 of file qmovie.cpp.
|
explicit |
Constructs a QMovie object.
QMovie will use read image data from fileName. 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.
The parent object is passed to QObject's constructor.
Definition at line 605 of file qmovie.cpp.
QMovie::~QMovie | ( | ) |
Destructs the QMovie object.
Definition at line 619 of file qmovie.cpp.
QColor QMovie::backgroundColor | ( | ) | const |
Returns the background color of the movie.
If no background color has been assigned, an invalid QColor is returned.
Definition at line 723 of file qmovie.cpp.
QBindable< QMovie::CacheMode > QMovie::bindableCacheMode | ( | ) |
Definition at line 1049 of file qmovie.cpp.
QBindable< int > QMovie::bindableSpeed | ( | ) |
Definition at line 927 of file qmovie.cpp.
QMovie::CacheMode QMovie::cacheMode | ( | ) | const |
Definition at line 1037 of file qmovie.cpp.
int QMovie::currentFrameNumber | ( | ) | const |
Returns the sequence number of the current frame.
The number of the first frame in the movie is 0.
Definition at line 835 of file qmovie.cpp.
QImage QMovie::currentImage | ( | ) | const |
Returns the current frame as a QImage.
Definition at line 768 of file qmovie.cpp.
QPixmap QMovie::currentPixmap | ( | ) | const |
Returns the current frame as a QPixmap.
Definition at line 757 of file qmovie.cpp.
QIODevice * QMovie::device | ( | ) | const |
Returns the device QMovie reads image data from.
If no device has currently been assigned, \nullptr is returned.
Definition at line 644 of file qmovie.cpp.
|
signal |
This signal is emitted by QMovie when the error error occurred during playback.
QMovie will stop the movie, and enter QMovie::NotRunning state.
QString QMovie::fileName | ( | ) | const |
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 is returned.
Definition at line 671 of file qmovie.cpp.
|
signal |
This signal is emitted when the movie has finished.
QByteArray QMovie::format | ( | ) | const |
Returns the format that QMovie uses when decoding image data.
If no format has been assigned, an empty QByteArray() is returned.
Definition at line 699 of file qmovie.cpp.
|
signal |
This signal is emitted when the frame number has changed to frameNumber.
You can call currentImage() or currentPixmap() 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.
Definition at line 815 of file qmovie.cpp.
QRect QMovie::frameRect | ( | ) | const |
Returns the rect of the last frame.
If no frame has yet been updated, an invalid QRect is returned.
Definition at line 746 of file qmovie.cpp.
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 lastError().
Definition at line 780 of file qmovie.cpp.
bool QMovie::jumpToFrame | ( | int | frameNumber | ) |
Jumps to frame number frameNumber.
Returns true
on success; otherwise returns false
.
Definition at line 854 of file qmovie.cpp.
|
slot |
Jumps to the next frame.
Returns true
on success; otherwise returns false
.
Definition at line 844 of file qmovie.cpp.
QImageReader::ImageReaderError QMovie::lastError | ( | ) | const |
Returns the most recent error that occurred while attempting to read image data.
Definition at line 791 of file qmovie.cpp.
QString QMovie::lastErrorString | ( | ) | const |
Returns a human-readable representation of the most recent error that occurred while attempting to read image data.
Definition at line 803 of file qmovie.cpp.
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), QMovie can only loop the movie if the cacheMode is set to QMovie::CacheAll.
Definition at line 869 of file qmovie.cpp.
int QMovie::nextFrameDelay | ( | ) | const |
Returns the number of milliseconds QMovie will wait before updating the next frame in the animation.
Definition at line 825 of file qmovie.cpp.
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() or currentPixmap() to get a copy of the updated frame.
QSize QMovie::scaledSize | ( | ) |
Returns the scaled size of frames.
Definition at line 978 of file qmovie.cpp.
For image formats that support it, this function sets the background color to color.
Definition at line 711 of file qmovie.cpp.
Definition at line 1043 of file qmovie.cpp.
Sets the current device to device.
QMovie will read image data from this device when the movie is running.
Definition at line 631 of file qmovie.cpp.
Sets the name of the file that QMovie reads image data from, to fileName.
Definition at line 656 of file qmovie.cpp.
void QMovie::setFormat | ( | const QByteArray & | format | ) |
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.
You can call supportedFormats() for the full list of formats QMovie supports.
Definition at line 687 of file qmovie.cpp.
|
slot |
If paused is true, QMovie will enter \l Paused state and emit stateChanged(Paused); otherwise it will enter \l Running state and emit stateChanged(Running).
Definition at line 882 of file qmovie.cpp.
Sets the scaled frame size to size.
Definition at line 989 of file qmovie.cpp.
|
slot |
Definition at line 908 of file qmovie.cpp.
int QMovie::speed | ( | ) | const |
Definition at line 921 of file qmovie.cpp.
|
slot |
Starts the movie.
QMovie will enter \l Running state, and start emitting updated() and resized() as the movie progresses.
If QMovie is in the \l Paused state, this function is equivalent to calling setPaused(false). If QMovie is already in the \l Running state, this function does nothing.
Definition at line 943 of file qmovie.cpp.
|
signal |
This signal is emitted after QMovie::start() has been called, and QMovie has entered QMovie::Running state.
QMovie::MovieState QMovie::state | ( | ) | const |
Returns the current state of QMovie.
Definition at line 734 of file qmovie.cpp.
|
signal |
This signal is emitted every time the state of the movie changes.
The new state is specified by state.
|
slot |
Stops the movie.
QMovie enters \l NotRunning state, and stops emitting updated() and resized(). If start() is called again, the movie will restart from the beginning.
If QMovie is already in the \l NotRunning state, this function does nothing.
Definition at line 963 of file qmovie.cpp.
|
static |
Returns the list of image formats supported by QMovie.
Definition at line 1000 of file qmovie.cpp.
This signal is emitted when the rect rect in the current frame has been updated.
You can call currentImage() or currentPixmap() to get a copy of the updated frame.
|
readwrite |
the movie's cache mode
Caching frames can be useful when the underlying animation format handler that QMovie 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 QMovie 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 \l CacheNone.
|
readwrite |