QMovieclass is a convenience class for playing movies withQImageReader. 更多 …
def
backgroundColor
()
def
cacheMode
()
def
currentFrameNumber
()
def
currentImage
()
def
currentPixmap
()
def
device
()
def
fileName
()
def
format
()
def
frameCount
()
def
frameRect
()
def
isValid
()
def
jumpToFrame
(frameNumber)
def
lastError
()
def
lastErrorString
()
def
loopCount
()
def
nextFrameDelay
()
def
scaledSize
()
def
setBackgroundColor
(color)
def
setCacheMode
(mode)
def
setDevice
(device)
def
setFileName
(fileName)
def
setFormat
(format)
def
setScaledSize
(size)
def
speed
()
def
state
()
def
jumpToNextFrame
()
def
setPaused
(paused)
def
setSpeed
(percentSpeed)
def
start
()
def
stop
()
def
error
(error)
def
finished
()
def
frameChanged
(frameNumber)
def
resized
(size)
def
started
()
def
stateChanged
(state)
def
updated
(rect)
def
supportedFormats
()
This class is used to show simple animations without sound. If you want to display video and media content, use the Qt Multimedia multimedia framework instead.
First, create a
QMovieobject by passing either the name of a file or a pointer to aQIODevicecontaining an animated image format toQMovie‘s constructor. You can callisValid()to check if the image data is valid, before starting the movie. To start the movie, callstart().QMovie将进入运行state, and emitstarted()andstateChanged(). To get the current state of the movie, callstate().To display the movie in your application, you can pass your
QMovie对象到setMovie()。范例:label = QLabel() movie = QMovie("animations/fire.gif") label.setMovie(movie) movie.start()Whenever a new frame is available in the movie,
QMovie将发射updated(). If the size of the frame changes,resized()is emitted. You can callcurrentImage()orcurrentPixmap()to get a copy of the current frame. When the movie is done,QMovie发射finished(). If any error occurs during playback (i.e, the image file is corrupt),QMovie将发射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 callingsetPaused(true)。QMoviewill then enterPausedstate and emitstateChanged(). If you callsetPaused(false),QMoviewill reenter运行state and start the movie again. To stop the movie, callstop().Certain animation formats allow you to set the background color. You can call
setBackgroundColor()to set the color, orbackgroundColor()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 callloopCount()to get the number of times the movie should loop before finishing.nextFrameDelay()returns the number of milliseconds the current frame should be displayed.
QMoviecan be instructed to cache frames of an animation by callingsetCacheMode().调用
supportedFormats()for a list of formats thatQMovie支持。另请参阅
QMovie
(
device
[
,
format=QByteArray()
[
,
parent=None
]
]
)
¶
QMovie([parent=None])
QMovie(fileName[, format=QByteArray()[, parent=None]])
- param parent
QObject- param format
QByteArray- param device
QIODevice- param fileName
unicode
构造
QMovie
object, passing the
parent
对象到
QObject
‘s constructor.
PySide2.QtGui.QMovie.
MovieState
¶
此枚举描述不同状态为
QMovie
.
|
常量 |
描述 |
|---|---|
|
QMovie.NotRunning |
The movie is not running. This is
|
|
QMovie.Paused |
The movie is paused, and
|
|
QMovie.Running |
The movie is running. |
PySide2.QtGui.QMovie.
CacheMode
¶
此枚举描述不同缓存模式,为
QMovie
.
|
常量 |
描述 |
|---|---|
|
QMovie.CacheNone |
没有帧被缓存 (默认)。 |
|
QMovie.CacheAll |
所有帧都被缓存。 |
PySide2.QtGui.QMovie.
backgroundColor
(
)
¶
Returns the background color of the movie. If no background color has been assigned, an invalid
QColor
被返回。
另请参阅
PySide2.QtGui.QMovie.
cacheMode
(
)
¶
另请参阅
PySide2.QtGui.QMovie.
currentFrameNumber
(
)
¶
int
Returns the sequence number of the current frame. The number of the first frame in the movie is 0.
PySide2.QtGui.QMovie.
device
(
)
¶
QIODevice
Returns the device
QMovie
reads image data from. If no device has currently been assigned,
None
被返回。
另请参阅
PySide2.QtGui.QMovie.
error
(
error
)
¶
error
–
ImageReaderError
PySide2.QtGui.QMovie.
fileName
(
)
¶
unicode
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
被返回。
另请参阅
PySide2.QtGui.QMovie.
finished
(
)
¶
PySide2.QtGui.QMovie.
format
(
)
¶
QByteArray
Returns the format that
QMovie
uses when decoding image data. If no format has been assigned, an empty QByteArray() is returned.
另请参阅
PySide2.QtGui.QMovie.
frameChanged
(
frameNumber
)
¶
frameNumber
–
int
PySide2.QtGui.QMovie.
frameCount
(
)
¶
int
Returns the number of frames in the movie.
Certain animation formats do not support this feature, in which case 0 is returned.
PySide2.QtGui.QMovie.
frameRect
(
)
¶
QRect
Returns the rect of the last frame. If no frame has yet been updated, an invalid
QRect
被返回。
PySide2.QtGui.QMovie.
isValid
(
)
¶
bool
返回
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()
.
PySide2.QtGui.QMovie.
jumpToFrame
(
frameNumber
)
¶
frameNumber
–
int
bool
Jumps to frame number
frameNumber
。返回
true
当成功时;否则返回
false
.
PySide2.QtGui.QMovie.
jumpToNextFrame
(
)
¶
bool
Jumps to the next frame. Returns
true
当成功时;否则返回
false
.
PySide2.QtGui.QMovie.
lastError
(
)
¶
ImageReaderError
Returns the most recent error that occurred while attempting to read image data.
另请参阅
PySide2.QtGui.QMovie.
lastErrorString
(
)
¶
unicode
Returns a human-readable representation of the most recent error that occurred while attempting to read image data.
另请参阅
PySide2.QtGui.QMovie.
loopCount
(
)
¶
int
Returns the number of times the movie will loop before it finishes. If the movie will only play once (no looping), returns 0. If the movie loops forever, 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
CacheAll
.
PySide2.QtGui.QMovie.
nextFrameDelay
(
)
¶
int
Returns the number of milliseconds
QMovie
will wait before updating the next frame in the animation.
PySide2.QtGui.QMovie.
resized
(
size
)
¶
size
–
QSize
PySide2.QtGui.QMovie.
scaledSize
(
)
¶
QSize
Returns the scaled size of frames.
PySide2.QtGui.QMovie.
setBackgroundColor
(
color
)
¶
color
–
QColor
For image formats that support it, this function sets the background color to
color
.
另请参阅
PySide2.QtGui.QMovie.
setDevice
(
device
)
¶
device
–
QIODevice
把当前设备设为
device
.
QMovie
will read image data from this device when the movie is running.
另请参阅
PySide2.QtGui.QMovie.
setFileName
(
fileName
)
¶
fileName – unicode
Sets the name of the file that
QMovie
reads image data from, to
fileName
.
PySide2.QtGui.QMovie.
setFormat
(
format
)
¶
format
–
QByteArray
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
支持。
PySide2.QtGui.QMovie.
setPaused
(
paused
)
¶
paused
–
bool
若
paused
is true,
QMovie
将进入
Paused
state and emit
stateChanged
(Paused); otherwise it will enter
运行
state and emit
stateChanged
(Running).
另请参阅
PySide2.QtGui.QMovie.
setScaledSize
(
size
)
¶
size
–
QSize
Sets the scaled frame size to
size
.
PySide2.QtGui.QMovie.
speed
(
)
¶
int
另请参阅
PySide2.QtGui.QMovie.
start
(
)
¶
Starts the movie.
QMovie
将进入
运行
state, and start emitting
updated()
and
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.
另请参阅
PySide2.QtGui.QMovie.
started
(
)
¶
PySide2.QtGui.QMovie.
state
(
)
¶
返回当前状态,为
QMovie
.
另请参阅
MovieState
stateChanged()
PySide2.QtGui.QMovie.
stateChanged
(
state
)
¶
state
–
MovieState
PySide2.QtGui.QMovie.
stop
(
)
¶
停止电影。
QMovie
进入
NotRunning
state, and stops emitting
updated()
and
resized()
。若
start()
is called again, the movie will restart from the beginning.
若
QMovie
is already in the
NotRunning
state, this function does nothing.
另请参阅
PySide2.QtGui.QMovie.
supportedFormats
(
)
¶
Returns the list of image formats supported by
QMovie
.
PySide2.QtGui.QMovie.
updated
(
rect
)
¶
rect
–
QRect