我想在 currentFrameNumber 等于 frameCount 时使用 frameChanged(int) 发出信号,我的 QT 版本是 4.7.4
QObject::connect(movie,SIGNAL(frameChanged(int)),movie,SLOT(stop()));
QMovieChild.cpp:
class QMovieChild:public QMovie
{
signals:
void newSignal();
public slots:
void onFrameChanged(int frameNumber){
if(frameNumber == this->frameCount()-2)
emit newSignal();
}
};
怪物.cpp:
void Monster::Vanishment()
{
QMovieChild *movie = new QMovieChild();
movie->setFileName("./pikaqiu.gif");
QSize size = this->getLabelPointer()->size();
movie->setScaledSize(size);
this->getLabelPointer()->setMovie(movie);
QMovie::connect(movie,SIGNAL(newSignal()),movie,SLOT(deleteLater()));
QMovie::connect(movie,SIGNAL(frameChanged(int)),movie,SLOT(onFrameChanged(int)));
movie->start();
}