返回介绍

QMovie Class

发布于 2019-10-04 15:01:44 字数 14752 浏览 1094 评论 0 收藏 0

The QMovie class provides incremental loading of animations or images, signalling as it progresses. More...

#include <qmovie.h>

List of all member functions.

Public Members

  • QMovie ()
  • QMovie ( intbufsize )
  • QMovie ( QDataSource*src, intbufsize = 1024 )
  • QMovie ( constQString&fileName, intbufsize = 1024 )
  • QMovie ( QByteArraydata, intbufsize = 1024 )
  • QMovie ( constQMovie&movie )
  • ~QMovie ()
  • QMovie & operator= ( constQMovie&movie )
  • int pushSpace () const
  • void pushData ( constuchar*data, intlength )
  • const QColor & backgroundColor () const
  • void setBackgroundColor ( constQColor&c )
  • const QRect & getValidRect () const
  • const QPixmap & framePixmap () const
  • const QImage & frameImage () const
  • bool isNull () const
  • int frameNumber () const
  • int steps () const
  • bool paused () const
  • bool finished () const
  • bool running () const
  • void unpause ()
  • void pause ()
  • void step ()
  • void step ( intsteps )
  • void restart ()
  • int speed () const
  • void setSpeed ( intpercent )
  • void connectResize ( QObject*receiver, constchar*member )
  • void disconnectResize ( QObject*receiver, constchar*member = 0 )
  • void connectUpdate ( QObject*receiver, constchar*member )
  • void disconnectUpdate ( QObject*receiver, constchar*member = 0 )
  • enum Status { SourceEmpty = -2, UnrecognizedFormat = -1, Paused = 1, EndOfFrame = 2, EndOfLoop = 3, EndOfMovie = 4, SpeedChanged = 5 }
  • void connectStatus ( QObject*receiver, constchar*member )
  • void disconnectStatus ( QObject*receiver, constchar*member = 0 )

Detailed Description

The QMovie class provides incremental loading of animations or images, signalling as it progresses.

The simplest way to display a QMovie is to use a QLabel and QLabel::setMovie().

A QMovie provides a QPixmap as the framePixmap(); connections can be made via connectResize() and connectUpdate() to receive notification of size and pixmap changes. All decoding is driven by the normal event-processing mechanisms.

The movie begins playing as soon as the QMovie is created (actually, once control returns to the event loop). When the last frame in the movie has been played, it may loop back to the start if such looping is defined in the input source.

QMovie objects are explicitly shared. This means that a QMovie copied from another QMovie will be displaying the same frame at all times. If one shared movie pauses, all pause. To make independent movies, they must be constructed separately.

The set of data formats supported by QMovie is determined by the decoder factories that have been installed; the format of the input is determined as the input is decoded.

The supported formats are MNG (if Qt is configured with MNG support enabled) and GIF (if Qt is configured with GIF support enabled, see qgif.h).

If Qt is configured to support GIF reading, we are required to state that "The Graphics Interchange Format(c) is the Copyright property of CompuServe Incorporated. GIF(sm) is a Service Mark property of CompuServe Incorporated.

Warning: If you are in a country that recognizes software patents and in which Unisys holds a patent on LZW compression and/or decompression and you want to use GIF, Unisys may require you to license that technology. Such countries include Canada, Japan, the USA, France, Germany, Italy and the UK.

GIF support may be removed completely in a future version of Qt. We recommend using the MNG or PNG format.

QMovie

See also QLabel::setMovie(), Graphics Classes, Image Processing Classes and Multimedia Classes.


Member Type Documentation

QMovie::Status

  • QMovie::SourceEmpty
  • QMovie::UnrecognizedFormat
  • QMovie::Paused
  • QMovie::EndOfFrame
  • QMovie::EndOfLoop
  • QMovie::EndOfMovie
  • QMovie::SpeedChanged

Member Function Documentation

QMovie::QMovie ()

Constructs a null QMovie. The only interesting thing to do with such a movie is to assign another movie to it.

See also isNull().

QMovie::QMovie ( intbufsize )

Constructs a QMovie with an external data source. You should later call pushData() to send incoming animation data to the movie.

The bufsize argument sets the maximum amount of data the movie will transfer from the data source per event loop. The lower this value, the better interleaved the movie playback will be with other event processing, but the slower the overall processing will be.

See also pushData().

QMovie::QMovie ( QDataSource*src, intbufsize = 1024 )

Constructs a QMovie that reads an image sequence from the given data source, src. The source must be allocated dynamically, because QMovie will take ownership of it and will destroy it when the movie is destroyed. The movie starts playing as soon as event processing continues.

The bufsize argument sets the maximum amount of data the movie will transfer from the data source per event loop. The lower this value, the better interleaved the movie playback will be with other event processing, but the slower the overall processing will be.

QMovie::QMovie ( constQString&fileName, intbufsize = 1024 )

Constructs a QMovie that reads an image sequence from the file, fileName.

The bufsize argument sets the maximum amount of data the movie will transfer from the data source per event loop. The lower this value, the better interleaved the movie playback will be with other event processing, but the slower the overall processing will be.

QMovie::QMovie ( QByteArraydata, intbufsize = 1024 )

Constructs a QMovie that reads an image sequence from the byte array, data.

The bufsize argument sets the maximum amount of data the movie will transfer from the data source per event loop. The lower this value, the better interleaved the movie playback will be with other event processing, but the slower the overall processing will be.

QMovie::QMovie ( constQMovie&movie )

Constructs a movie that uses the same data as movie movie. QMovies use explicit sharing, so operations on the copy will affect both.

QMovie::~QMovie ()

Destroys the QMovie. If this is the last reference to the data of the movie, the data is deallocated.

constQColor& QMovie::backgroundColor () const

Returns the background color of the movie set by setBackgroundColor().

void QMovie::connectResize ( QObject*receiver, constchar*member )

Connects the receiver's member of type void member(const QSize&) so that it is signalled when the movie changes size.

Note that due to the explicit sharing of QMovie objects, these connections persist until they are explicitly disconnected with disconnectResize() or until every shared copy of the movie is deleted.

Example: movies/main.cpp.

void QMovie::connectStatus ( QObject*receiver, constchar*member )

Connects the receiver's member, of type void member(int) so that it is signalled when the movie changes status. The status codes are negative for errors and positive for information.

Status CodeMeaning
QMovie::SourceEmptysignalled if the input cannot be read.
QMovie::UnrecognizedFormatsignalled if the input data is unrecognized.
QMovie::Pausedsignalled when the movie is paused by a call to paused() or by after stepping pauses.
QMovie::EndOfFramesignalled at end-of-frame after any update and Paused signals.
QMovie::EndOfLoopsignalled at end-of-loop, after any update signals, EndOfFrame - but before EndOfMovie.
QMovie::EndOfMoviesignalled when the movie completes and is not about to loop.

More status messages may be added in the future, so a general test for errors would test for negative.

Note that due to the explicit sharing of QMovie objects, these connections persist until they are explicitly disconnected with disconnectStatus() or until every shared copy of the movie is deleted.

Example: movies/main.cpp.

void QMovie::connectUpdate ( QObject*receiver, constchar*member )

Connects the receiver's member of type void member(const QRect&) so that it is signalled when an area of the framePixmap() has changed since the previous frame.

Note that due to the explicit sharing of QMovie objects, these connections persist until they are explicitly disconnected with disconnectUpdate() or until every shared copy of the movie is deleted.

Example: movies/main.cpp.

void QMovie::disconnectResize ( QObject*receiver, constchar*member = 0 )

Disconnects the receiver's member (or all members if member is zero) that were previously connected by connectResize().

void QMovie::disconnectStatus ( QObject*receiver, constchar*member = 0 )

Disconnects the receiver's member (or all members if member is zero) that were previously connected by connectStatus().

void QMovie::disconnectUpdate ( QObject*receiver, constchar*member = 0 )

Disconnects the receiver's member (or all members if \q member is zero) that were previously connected by connectUpdate().

bool QMovie::finished () const

Returns TRUE if the image is no longer playing: this happens when all loops of all frames are complete; otherwise returns FALSE.

Example: movies/main.cpp.

constQImage& QMovie::frameImage () const

Returns the current frame of the movie, as a QImage. It is not generally useful to keep a copy of this image. Also note that you must not call this function if the movie is finished(), since by then the image will not be available.

See also framePixmap().

int QMovie::frameNumber () const

Returns the number of times EndOfFrame has been emitted since the start of the current loop of the movie. Thus, before any EndOfFrame has been emitted the value will be 0; within slots processing the first signal, frameNumber() will be 1, and so on.

constQPixmap& QMovie::framePixmap () const

Returns the current frame of the movie, as a QPixmap. It is not generally useful to keep a copy of this pixmap. It is better to keep a copy of the QMovie and get the framePixmap() only when needed for drawing.

See also frameImage().

Example: movies/main.cpp.

constQRect& QMovie::getValidRect () const

Returns the area of the pixmap for which pixels have been generated.

bool QMovie::isNull () const

Returns TRUE if the movie is null; otherwise returns FALSE.

QMovie& QMovie::operator= ( constQMovie&movie )

Makes this movie use the same data as movie movie. QMovies use explicit sharing.

void QMovie::pause ()

Pauses the progress of the animation.

See also unpause().

Example: movies/main.cpp.

bool QMovie::paused () const

Returns TRUE if the image is paused; otherwise returns FALSE.

Example: movies/main.cpp.

void QMovie::pushData ( constuchar*data, intlength )

Pushes length bytes from data into the movie. length must be no more than the amount returned by pushSpace() since the previous call to pushData().

int QMovie::pushSpace () const

Returns the maximum amount of data that can currently be pushed into the movie by a call to pushData(). This is affected by the initial buffer size, but varies as the movie plays and data is consumed.

void QMovie::restart ()

Rewinds the movie to the beginning. If the movie has not been paused, it begins playing again.

Example: movies/main.cpp.

bool QMovie::running () const

Returns TRUE if the image is not single-stepping, not paused, and not finished; otherwise returns FALSE.

void QMovie::setBackgroundColor ( constQColor&c )

Sets the background color of the pixmap to c. If the background color isValid(), the pixmap will never have a mask because the background color will be used in transparent regions of the image.

See also backgroundColor().

void QMovie::setSpeed ( intpercent )

Sets the movie's play speed as a percentage, to percent. This is a percentage of the speed dictated by the input data format. The default is 100 percent.

int QMovie::speed () const

Returns the movie's play speed as a percentage. The default is 100 percent.

See also setSpeed().

void QMovie::step ()

Steps forward 1 frame and then pauses.

Example: movies/main.cpp.

void QMovie::step ( intsteps )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Steps forward, showing steps frames, and then pauses.

int QMovie::steps () const

Returns the number of steps remaining after a call to step(). If the movie is paused, steps() returns 0. If it's running normally or is finished, steps() returns a negative number.

Example: movies/main.cpp.

void QMovie::unpause ()

Unpauses the progress of the animation.

See also pause().

Example: movies/main.cpp.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文