1 使用QLabel 显示
QMovie *movie = new QMovie(":/images/timg.gif");//这个资源不用写到source.qrc中,只要路径对了就行,还有就是movie最好是new的
QLabel *label = new QLabel(this);
label->setGeometry(1024, 333, 400, 300);
label->setMovie(movie);
movie->start();
2 在paintEvent中画出每一帧
m_movie = new QMovie(gifImagePath);
if (m_movie)
{
m_movie->setSpeed(50);
m_movie->start();
connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(update()));
}
void xxx::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
if (m_movie != NULL)
{
// show gif
painter.drawPixmap(rect(),m_movie->currentPixmap());
}
}