|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QMovie
public class QMovie
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 = new QLabel(); 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.
QLabel
, QImageReader
, and Movie Example.
Nested Class Summary | |
---|---|
static class |
QMovie.CacheMode
This enum describes the different cache modes of QMovie . |
static class |
QMovie.MovieState
This enum describes the different states of QMovie . |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary | |
---|---|
QSignalEmitter.Signal1 |
error
This signal takes 1 generic argument(s). |
QSignalEmitter.Signal0 |
finished
This signal is emitted when the movie has finished. |
QSignalEmitter.Signal1 |
frameChanged
This signal takes 1 generic argument(s). |
QSignalEmitter.Signal1 |
resized
This signal takes 1 generic argument(s). |
QSignalEmitter.Signal0 |
started
This signal is emitted after QMovie::start() has been called, and QMovie has entered QMovie::Running state. |
QSignalEmitter.Signal1 |
stateChanged
This signal takes 1 generic argument(s). |
QSignalEmitter.Signal1 |
updated
This signal takes 1 generic argument(s). |
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QMovie()
Constructs a QMovie object, passing the parent object to QObject 's constructor. |
|
QMovie(QIODevice device)
Constructs a QMovie object. |
|
QMovie(QIODevice device,
QByteArray format)
Constructs a QMovie object. |
|
QMovie(QIODevice device,
QByteArray format,
QObject parent)
Constructs a QMovie object. |
|
QMovie(QObject parent)
Constructs a QMovie object, passing the parent object to QObject 's constructor. |
|
QMovie(java.lang.String fileName)
Constructs a QMovie object. |
|
QMovie(java.lang.String fileName,
QByteArray format)
Constructs a QMovie object. |
|
QMovie(java.lang.String fileName,
QByteArray format,
QObject parent)
Constructs a QMovie object. |
Method Summary | |
---|---|
QColor |
backgroundColor()
Returns the background color of the movie. |
QMovie.CacheMode |
cacheMode()
This property holds the movie's cache mode. |
int |
currentFrameNumber()
Returns the sequence number of the current frame. |
QImage |
currentImage()
Returns the current frame as a QImage . |
QPixmap |
currentPixmap()
Returns the current frame as a QPixmap . |
QIODevice |
device()
Returns the device QMovie reads image data from. |
java.lang.String |
fileName()
Returns the name of the file that QMovie reads image data from. |
QByteArray |
format()
Returns the format that QMovie uses when decoding image data. |
int |
frameCount()
Returns the number of frames in the movie. |
QRect |
frameRect()
Returns the rect of the last frame. |
boolean |
isValid()
Returns true if the movie is valid (e.g., the image data is readable and the image format is supported); otherwise returns false. |
boolean |
jumpToFrame(int frameNumber)
Jumps to frame number frameNumber. |
boolean |
jumpToNextFrame()
Jumps to the next frame. |
int |
loopCount()
Returns the number of times the movie will loop before it finishes. |
int |
nextFrameDelay()
Returns the number of milliseconds QMovie will wait before updating the next frame in the animation. |
QSize |
scaledSize()
Returns the scaled size of frames. |
void |
setBackgroundColor(QColor color)
For image formats that support it, this function sets the background color to color. |
void |
setCacheMode(QMovie.CacheMode mode)
This property holds the movie's cache mode. |
void |
setDevice(QIODevice device)
Sets the current device to device. |
void |
setFileName(java.lang.String fileName)
Sets the name of the file that QMovie reads image data from, to fileName. |
void |
setFormat(QByteArray format)
Sets the format that QMovie will use when decoding image data, to format. |
void |
setPaused(boolean paused)
If paused is true, QMovie will enter Paused state and emit stateChanged(Paused); otherwise it will enter Running state and emit stateChanged(Running). |
void |
setScaledSize(QSize size)
Sets the scaled frame size to size. |
void |
setSpeed(int percentSpeed)
This property holds the movie's speed. |
int |
speed()
This property holds the movie's speed. |
void |
start()
Starts the movie. |
QMovie.MovieState |
state()
Returns the current state of QMovie. |
void |
stop()
Stops the movie. |
static java.util.List |
supportedFormats()
Returns the list of image formats supported by QMovie. |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public final QSignalEmitter.Signal1 error
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.gui.QImageReader$ImageReaderError(named: error)>:
This signal is emitted by QMovie when the error error occurred during playback. QMovie will stop the movie, and enter QMovie::NotRunning
state.
public final QSignalEmitter.Signal0 finished
QMovie::stop()
.
public final QSignalEmitter.Signal1 frameChanged
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: frameNumber)>:
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.
public final QSignalEmitter.Signal1 resized
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QSize(named: 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 currentImage()
or currentPixmap()
to get a copy of the updated frame.
public final QSignalEmitter.Signal0 started
QMovie::start()
has been called, and QMovie has entered QMovie::Running
state.
public final QSignalEmitter.Signal1 stateChanged
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.gui.QMovie$MovieState(named: state)>:
This signal is emitted every time the state of the movie changes. The new state is specified by state.
QMovie::state()
.
public final QSignalEmitter.Signal1 updated
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QRect(named: rect)>:
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.
Constructor Detail |
---|
public QMovie(QIODevice device, QByteArray format)
The parent object is passed to QObject
's constructor.
public QMovie(QIODevice device)
The parent object is passed to QObject
's constructor.
public QMovie(QIODevice device, QByteArray format, QObject parent)
The parent object is passed to QObject
's constructor.
public QMovie()
QObject
's constructor. setFileName()
, setDevice()
, and setFormat()
.
public QMovie(QObject parent)
QObject
's constructor. setFileName()
, setDevice()
, and setFormat()
.
public QMovie(java.lang.String fileName, QByteArray format)
The parent object is passed to QObject
's constructor.
public QMovie(java.lang.String fileName)
The parent object is passed to QObject
's constructor.
public QMovie(java.lang.String fileName, QByteArray format, QObject parent)
The parent object is passed to QObject
's constructor.
Method Detail |
---|
public final QColor backgroundColor()
QColor
is returned. setBackgroundColor()
.
public final QMovie.CacheMode cacheMode()
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
.
QMovie::CacheMode
.
public final int currentFrameNumber()
public final QImage currentImage()
QImage
. currentPixmap()
, and updated()
.
public final QPixmap currentPixmap()
QPixmap
. currentImage()
, and updated()
.
public final QIODevice device()
setDevice()
, and fileName()
.
public final java.lang.String fileName()
setFileName()
, and device()
.
public final QByteArray format()
setFormat()
.
public final int frameCount()
Certain animation formats do not support this feature, in which case 0 is returned.
public final QRect frameRect()
QRect
is returned. currentImage()
, and currentPixmap()
.
public final boolean isValid()
public final boolean jumpToFrame(int frameNumber)
public final boolean jumpToNextFrame()
public final int loopCount()
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
.
public final int nextFrameDelay()
public final QSize scaledSize()
setScaledSize()
, and QImageReader::scaledSize()
.
public final void setBackgroundColor(QColor color)
backgroundColor()
.
public final void setCacheMode(QMovie.CacheMode mode)
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
.
QMovie::CacheMode
.
public final void setDevice(QIODevice device)
device()
, and setFormat()
.
public final void setFileName(java.lang.String fileName)
fileName()
, setDevice()
, and setFormat()
.
public final void setFormat(QByteArray format)
You can call supportedFormats()
for the full list of formats QMovie supports.
format()
, and QImageReader::supportedImageFormats()
.
public final void setPaused(boolean paused)
Paused
state and emit stateChanged(Paused); otherwise it will enter Running
state and emit stateChanged(Running). state()
.
public final void setScaledSize(QSize size)
scaledSize()
, and QImageReader::setScaledSize()
.
public final void setSpeed(int percentSpeed)
QMovie movie = new QMovie("racecar.gif"); movie.setSpeed(200); // 2x speed
public final int speed()
QMovie movie = new QMovie("racecar.gif"); movie.setSpeed(200); // 2x speed
public final void start()
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.
stop()
, and setPaused()
.
public final QMovie.MovieState state()
MovieState
, and stateChanged()
.
public final void stop()
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.
start()
, and setPaused()
.
public static java.util.List supportedFormats()
QImageReader::supportedImageFormats()
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |