如何使用frameChanged(int)来判断帧是最后一帧,我想使用该信号来阻止Qmovie播放一次而不是永久播放。
QMovie *movie = new QMovie();
movie->setFileName("C:/Qt/qtcreator-2.2.1/game/test/pikaqiu.gif");
QSize size = this->getLabelPointer()->size();
movie->setScaledSize(size);
this->getLabelPointer()->setMovie(movie);
QObject::connect(movie,SIGNAL(finished()),movie,SLOT(deleteLater()));
movie->start();
enter code here
delete this;
movie->stop();
`
答案 0 :(得分:0)
您必须使用frameCount()
函数来获取QMovie的帧数。
QMovie *movie = new QMovie();
movie->setFileName("download.gif");
ui->label->setMovie(movie);
connect(movie, &QMovie::frameChanged, [=](int frameNumber){
if(frameNumber == movie->frameCount()-1){
movie->stop();
movie->deleteLater();
}
});
movie->start();