Qt 4.8
Public Types | Public Slots | Signals | Public Functions | Static Public Functions | Properties | List of all members
QMovie Class Reference

The QMovie class is a convenience class for playing movies with QImageReader. More...

#include <qmovie.h>

Inheritance diagram for QMovie:
QObject

Public Types

enum  CacheMode { CacheNone, CacheAll }
 This enum describes the different cache modes of QMovie. More...
 
enum  MovieState { NotRunning, Paused, Running }
 This enum describes the different states of QMovie. More...
 

Public Slots

bool jumpToNextFrame ()
 Jumps to the next frame. More...
 
void setPaused (bool paused)
 If paused is true, QMovie will enter Paused state and emit stateChanged(Paused); otherwise it will enter Running state and emit stateChanged(Running). More...
 
void setSpeed (int percentSpeed)
 
void start ()
 Starts the movie. More...
 
void stop ()
 Stops the movie. More...
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void error (QImageReader::ImageReaderError error)
 This signal is emitted by QMovie when the error error occurred during playback. More...
 
void finished ()
 This signal is emitted when the movie has finished. More...
 
void frameChanged (int frameNumber)
 This signal is emitted when the frame number has changed to frameNumber. More...
 
void resized (const QSize &size)
 This signal is emitted when the current frame has been resized to size. More...
 
void started ()
 This signal is emitted after QMovie::start() has been called, and QMovie has entered QMovie::Running state. More...
 
void stateChanged (QMovie::MovieState state)
 This signal is emitted every time the state of the movie changes. More...
 
void updated (const QRect &rect)
 This signal is emitted when the rect rect in the current frame has been updated. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

QColor backgroundColor () const
 Returns the background color of the movie. More...
 
CacheMode cacheMode () const
 
CacheMode cacheMode ()
 
int currentFrameNumber () const
 Returns the sequence number of the current frame. More...
 
QImage currentImage () const
 Returns the current frame as a QImage. More...
 
QPixmap currentPixmap () const
 Returns the current frame as a QPixmap. More...
 
QIODevicedevice () const
 Returns the device QMovie reads image data from. More...
 
QString fileName () const
 Returns the name of the file that QMovie reads image data from. More...
 
QByteArray format () const
 Returns the format that QMovie uses when decoding image data. More...
 
int frameCount () const
 Returns the number of frames in the movie. More...
 
QRect frameRect () const
 Returns the rect of the last frame. More...
 
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. More...
 
bool jumpToFrame (int frameNumber)
 Jumps to frame number frameNumber. More...
 
int loopCount () const
 Returns the number of times the movie will loop before it finishes. More...
 
int nextFrameDelay () const
 Returns the number of milliseconds QMovie will wait before updating the next frame in the animation. More...
 
 QMovie (QObject *parent=0)
 Constructs a QMovie object, passing the parent object to QObject's constructor. More...
 
 QMovie (QIODevice *device, const QByteArray &format=QByteArray(), QObject *parent=0)
 Constructs a QMovie object. More...
 
 QMovie (const QString &fileName, const QByteArray &format=QByteArray(), QObject *parent=0)
 Constructs a QMovie object. More...
 
QSize scaledSize ()
 Returns the scaled size of frames. More...
 
void setBackgroundColor (const QColor &color)
 For image formats that support it, this function sets the background color to color. More...
 
void setCacheMode (CacheMode mode)
 
void setDevice (QIODevice *device)
 Sets the current device to device. More...
 
void setFileName (const QString &fileName)
 Sets the name of the file that QMovie reads image data from, to fileName. More...
 
void setFormat (const QByteArray &format)
 Sets the format that QMovie will use when decoding image data, to format. More...
 
void setScaledSize (const QSize &size)
 Sets the scaled frame size to size. More...
 
int speed () const
 
MovieState state () const
 Returns the current state of QMovie. More...
 
 ~QMovie ()
 Destructs the QMovie object. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) 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. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
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. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Static Public Functions

static QList< QByteArraysupportedFormats ()
 Returns the list of image formats supported by QMovie. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Properties

CacheMode cacheMode
 the movie's cache mode More...
 
int speed
 the movie's speed More...
 

Additional Inherited Members

- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

The QMovie class is a convenience class for playing movies with QImageReader.

This class is used to show simple animations without sound. If you want to display video and media content, use the Phonon Module{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 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, {Movie Example}

Definition at line 74 of file qmovie.h.

Enumerations

◆ CacheMode

This enum describes the different cache modes of QMovie.

  • CacheNone No frames are cached (the default).
  • CacheAll All frames are cached.
Enumerator
CacheNone 
CacheAll 

Definition at line 87 of file qmovie.h.

87  {
88  CacheNone,
89  CacheAll
90  };

◆ MovieState

This enum describes the different states of QMovie.

  • 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.
  • 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.
  • Running The movie is running.
Enumerator
NotRunning 
Paused 
Running 

Definition at line 82 of file qmovie.h.

82  {
83  NotRunning,
84  Paused,
85  Running
86  };

Constructors and Destructors

◆ QMovie() [1/3]

QMovie::QMovie ( QObject parent = 0)

Constructs a QMovie object, passing the parent object to QObject's constructor.

See also
setFileName(), setDevice(), setFormat()

Definition at line 616 of file qmovie.cpp.

617  : QObject(*new QMoviePrivate(this), parent)
618 {
619  Q_D(QMovie);
620  d->reader = new QImageReader;
621  connect(&d->nextImageTimer, SIGNAL(timeout()), this, SLOT(_q_loadNextFrame()));
622 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define SLOT(a)
Definition: qobjectdefs.h:226
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
The QImageReader class provides a format independent interface for reading images from files or other...
Definition: qimagereader.h:62
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

◆ QMovie() [2/3]

QMovie::QMovie ( QIODevice device,
const QByteArray format = QByteArray(),
QObject parent = 0 
)
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 632 of file qmovie.cpp.

633  : QObject(*new QMoviePrivate(this), parent)
634 {
635  Q_D(QMovie);
636  d->reader = new QImageReader(device, format);
637  d->initialDevicePos = device->pos();
638  connect(&d->nextImageTimer, SIGNAL(timeout()), this, SLOT(_q_loadNextFrame()));
639 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define SLOT(a)
Definition: qobjectdefs.h:226
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from...
Definition: qiodevice.cpp:624
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
The QImageReader class provides a format independent interface for reading images from files or other...
Definition: qimagereader.h:62
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

◆ QMovie() [3/3]

QMovie::QMovie ( const QString fileName,
const QByteArray format = QByteArray(),
QObject parent = 0 
)
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 649 of file qmovie.cpp.

650  : QObject(*new QMoviePrivate(this), parent)
651 {
652  Q_D(QMovie);
653  d->absoluteFilePath = QDir(fileName).absolutePath();
654  d->reader = new QImageReader(fileName, format);
655  if (d->reader->device())
656  d->initialDevicePos = d->reader->device()->pos();
657  connect(&d->nextImageTimer, SIGNAL(timeout()), this, SLOT(_q_loadNextFrame()));
658 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define SLOT(a)
Definition: qobjectdefs.h:226
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
QString absolutePath() const
Returns the absolute path (a path that starts with "/" or with a drive specification), which may contain symbolic links, but never contains redundant ".", ".." or multiple separators.
Definition: qdir.cpp:619
The QImageReader class provides a format independent interface for reading images from files or other...
Definition: qimagereader.h:62
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

◆ ~QMovie()

QMovie::~QMovie ( )

Destructs the QMovie object.

Definition at line 663 of file qmovie.cpp.

664 {
665  Q_D(QMovie);
666  delete d->reader;
667 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

Functions

◆ backgroundColor()

QColor QMovie::backgroundColor ( ) const

Returns the background color of the movie.

If no background color has been assigned, an invalid QColor is returned.

See also
setBackgroundColor()

Definition at line 767 of file qmovie.cpp.

768 {
769  Q_D(const QMovie);
770  return d->reader->backgroundColor();
771 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ cacheMode() [1/2]

CacheMode QMovie::cacheMode ( ) const

Referenced by setCacheMode(), and supportedFormats().

◆ cacheMode() [2/2]

CacheMode QMovie::cacheMode ( )

◆ currentFrameNumber()

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 943 of file qmovie.cpp.

944 {
945  Q_D(const QMovie);
946  return d->currentFrameNumber;
947 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ currentImage()

QImage QMovie::currentImage ( ) const

Returns the current frame as a QImage.

See also
currentPixmap(), updated()

Definition at line 844 of file qmovie.cpp.

845 {
846  Q_D(const QMovie);
847  return d->currentPixmap.toImage();
848 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ currentPixmap()

QPixmap QMovie::currentPixmap ( ) const

Returns the current frame as a QPixmap.

See also
currentImage(), updated()

Definition at line 825 of file qmovie.cpp.

Referenced by QLabelPrivate::_q_movieUpdated(), and QLabelPrivate::sizeForWidth().

826 {
827  Q_D(const QMovie);
828  return d->currentPixmap;
829 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ device()

QIODevice * QMovie::device ( ) const

Returns the device QMovie reads image data from.

If no device has currently been assigned, 0 is returned.

See also
setDevice(), fileName()

Definition at line 688 of file qmovie.cpp.

689 {
690  Q_D(const QMovie);
691  return d->reader->device();
692 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ error

void QMovie::error ( QImageReader::ImageReaderError  error)
signal

This signal is emitted by QMovie when the error error occurred during playback.

QMovie will stop the movie, and enter QMovie::NotRunning state.

◆ fileName()

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.

See also
setFileName(), device()

Definition at line 715 of file qmovie.cpp.

716 {
717  Q_D(const QMovie);
718  return d->reader->fileName();
719 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ finished

bool QMovie::finished ( )
signal

This signal is emitted when the movie has finished.

Use state() instead.

See also
QMovie::stop()

◆ format()

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.

See also
setFormat()

Definition at line 743 of file qmovie.cpp.

744 {
745  Q_D(const QMovie);
746  return d->reader->format();
747 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ frameChanged

void QMovie::frameChanged ( int  frameNumber)
signal

This signal is emitted when the frame number has changed to frameNumber.

Since
4.1

You can call currentImage() or currentPixmap() to get a copy of the frame.

◆ frameCount()

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 923 of file qmovie.cpp.

924 {
925  Q_D(const QMovie);
926  return d->frameCount();
927 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ frameRect()

QRect QMovie::frameRect ( ) const

Returns the rect of the last frame.

If no frame has yet been updated, an invalid QRect is returned.

See also
currentImage(), currentPixmap()

Definition at line 790 of file qmovie.cpp.

791 {
792  Q_D(const QMovie);
793  return d->frameRect;
794 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ isValid()

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.

Definition at line 854 of file qmovie.cpp.

Referenced by QLabelPrivate::_q_movieUpdated().

855 {
856  Q_D(const QMovie);
857  return d->isValid();
858 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ jumpToFrame()

bool QMovie::jumpToFrame ( int  frameNumber)

Jumps to frame number frameNumber.

Returns true on success; otherwise returns false.

Definition at line 962 of file qmovie.cpp.

963 {
964  Q_D(QMovie);
965  return d->jumpToFrame(frameNumber);
966 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ jumpToNextFrame

bool QMovie::jumpToNextFrame ( )
slot

Jumps to the next frame.

Returns true on success; otherwise returns false.

Definition at line 952 of file qmovie.cpp.

953 {
954  Q_D(QMovie);
955  return d->jumpToNextFrame();
956 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ loopCount()

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 977 of file qmovie.cpp.

978 {
979  Q_D(const QMovie);
980  return d->reader->loopCount();
981 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ nextFrameDelay()

int QMovie::nextFrameDelay ( ) const

Returns the number of milliseconds QMovie will wait before updating the next frame in the animation.

Definition at line 933 of file qmovie.cpp.

Referenced by setPaused().

934 {
935  Q_D(const QMovie);
936  return d->nextDelay;
937 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ resized

void QMovie::resized ( const QSize size)
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() or currentPixmap() to get a copy of the updated frame.

◆ scaledSize()

QSize QMovie::scaledSize ( )

Returns the scaled size of frames.

Since
4.1
See also
QImageReader::scaledSize()

Definition at line 1080 of file qmovie.cpp.

1081 {
1082  Q_D(QMovie);
1083  return d->reader->scaledSize();
1084 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setBackgroundColor()

void QMovie::setBackgroundColor ( const QColor color)

For image formats that support it, this function sets the background color to color.

See also
backgroundColor()

Definition at line 755 of file qmovie.cpp.

756 {
757  Q_D(QMovie);
758  d->reader->setBackgroundColor(color);
759 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setCacheMode()

void QMovie::setCacheMode ( CacheMode  mode)

Definition at line 1156 of file qmovie.cpp.

1157 {
1158  Q_D(QMovie);
1159  d->cacheMode = cacheMode;
1160 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482
CacheMode cacheMode() const

◆ setDevice()

void QMovie::setDevice ( QIODevice device)

Sets the current device to device.

QMovie will read image data from this device when the movie is running.

See also
device(), setFormat()

Definition at line 675 of file qmovie.cpp.

676 {
677  Q_D(QMovie);
678  d->reader->setDevice(device);
679  d->reset();
680 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setFileName()

void QMovie::setFileName ( const QString fileName)

Sets the name of the file that QMovie reads image data from, to fileName.

See also
fileName(), setDevice(), setFormat()

Definition at line 700 of file qmovie.cpp.

701 {
702  Q_D(QMovie);
703  d->absoluteFilePath = QDir(fileName).absolutePath();
704  d->reader->setFileName(fileName);
705  d->reset();
706 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482
QString absolutePath() const
Returns the absolute path (a path that starts with "/" or with a drive specification), which may contain symbolic links, but never contains redundant ".", ".." or multiple separators.
Definition: qdir.cpp:619

◆ setFormat()

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.

See also
QImageReader::supportedImageFormats()

Definition at line 731 of file qmovie.cpp.

732 {
733  Q_D(QMovie);
734  d->reader->setFormat(format);
735 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setPaused

void QMovie::setPaused ( bool  paused)
slot

If paused is true, QMovie will enter Paused state and emit stateChanged(Paused); otherwise it will enter Running state and emit stateChanged(Running).

See also
state()

Definition at line 990 of file qmovie.cpp.

Referenced by start().

991 {
992  Q_D(QMovie);
993  if (paused) {
994  if (d->movieState == NotRunning)
995  return;
996  d->enterState(Paused);
997  d->nextImageTimer.stop();
998  } else {
999  if (d->movieState == Running)
1000  return;
1001  d->enterState(Running);
1002  d->nextImageTimer.start(nextFrameDelay());
1003  }
1004 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482
int nextFrameDelay() const
Returns the number of milliseconds QMovie will wait before updating the next frame in the animation...
Definition: qmovie.cpp:933

◆ setScaledSize()

void QMovie::setScaledSize ( const QSize size)

Sets the scaled frame size to size.

Since
4.1
See also
QImageReader::setScaledSize()

Definition at line 1096 of file qmovie.cpp.

1097 {
1098  Q_D(QMovie);
1099  d->reader->setScaledSize(size);
1100 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setSpeed

void QMovie::setSpeed ( int  percentSpeed)
slot

Definition at line 1019 of file qmovie.cpp.

1020 {
1021  Q_D(QMovie);
1022  d->speed = percentSpeed;
1023 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ speed()

int QMovie::speed ( ) const

Referenced by setSpeed().

◆ start

void QMovie::start ( )
slot

Starts the movie.

QMovie will enter Running state, and start emitting updated() and resized() as the movie progresses.

If QMovie is in the Paused state, this function is equivalent to calling setPaused(false). If QMovie is already in the Running state, this function does nothing.

See also
stop(), setPaused()

Definition at line 1040 of file qmovie.cpp.

1041 {
1042  Q_D(QMovie);
1043  if (d->movieState == NotRunning) {
1044  d->_q_loadNextFrame(true);
1045  } else if (d->movieState == Paused) {
1046  setPaused(false);
1047  }
1048 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482
void setPaused(bool paused)
If paused is true, QMovie will enter Paused state and emit stateChanged(Paused); otherwise it will en...
Definition: qmovie.cpp:990

◆ started

void QMovie::started ( )
signal

This signal is emitted after QMovie::start() has been called, and QMovie has entered QMovie::Running state.

◆ state()

QMovie::MovieState QMovie::state ( ) const

Returns the current state of QMovie.

See also
MovieState, stateChanged()

Definition at line 778 of file qmovie.cpp.

Referenced by QLabel::setMovie().

779 {
780  Q_D(const QMovie);
781  return d->movieState;
782 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ stateChanged

void QMovie::stateChanged ( QMovie::MovieState  state)
signal

This signal is emitted every time the state of the movie changes.

The new state is specified by state.

See also
QMovie::state()

◆ stop

void QMovie::stop ( )
slot

Stops the movie.

QMovie enters 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 NotRunning state, this function does nothing.

See also
start(), setPaused()

Definition at line 1060 of file qmovie.cpp.

1061 {
1062  Q_D(QMovie);
1063  if (d->movieState == NotRunning)
1064  return;
1065  d->enterState(NotRunning);
1066  d->nextImageTimer.stop();
1067  d->nextFrameNumber = 0;
1068 }
double d
Definition: qnumeric_p.h:62
The QMovie class is a convenience class for playing movies with QImageReader.
Definition: qmovie.h:74
#define Q_D(Class)
Definition: qglobal.h:2482

◆ supportedFormats()

QList< QByteArray > QMovie::supportedFormats ( )
static

Returns the list of image formats supported by QMovie.

Since
4.1
See also
QImageReader::supportedImageFormats()

Definition at line 1112 of file qmovie.cpp.

1113 {
1115  QMutableListIterator<QByteArray> it(list);
1116  QBuffer buffer;
1117  buffer.open(QIODevice::ReadOnly);
1118  while (it.hasNext()) {
1119  QImageReader reader(&buffer, it.next());
1120  if (!reader.supportsAnimation())
1121  it.remove();
1122  }
1123  return list;
1124 }
static QList< QByteArray > supportedImageFormats()
Returns the list of image formats supported by QImageReader.
#define it(className, varName)
bool open(OpenMode openMode)
Reimplemented Function
Definition: qbuffer.cpp:338
The QBuffer class provides a QIODevice interface for a QByteArray.
Definition: qbuffer.h:57
The QImageReader class provides a format independent interface for reading images from files or other...
Definition: qimagereader.h:62

◆ updated

void QMovie::updated ( const QRect rect)
signal

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.

Properties

◆ cacheMode

QMovie::CacheMode QMovie::cacheMode
private

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

See also
QMovie::CacheMode
Warning
This function is not part of the public interface.

Definition at line 80 of file qmovie.h.

◆ speed

int QMovie::speed
private

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 speed

Definition at line 79 of file qmovie.h.


The documentation for this class was generated from the following files: