28 lines
508 B
C++
28 lines
508 B
C++
#include "animlabel.h"
|
|
|
|
AnimLabel::AnimLabel(QWidget *parent) :
|
|
QLabel(parent)
|
|
{
|
|
startTimer(50);
|
|
}
|
|
|
|
|
|
void AnimLabel::setAnimation(const QStringList &anim)
|
|
{
|
|
for (int i=0; i<images.size(); ++i)
|
|
delete images[i];
|
|
images.clear();
|
|
for (int i=0; i<anim.size(); ++i)
|
|
images.append(new QPixmap(anim.at(i)));
|
|
imgIndex = 0;
|
|
}
|
|
|
|
|
|
void AnimLabel::timerEvent(QTimerEvent *)
|
|
{
|
|
if (images.isEmpty()) return;
|
|
if (imgIndex >= images.size()) imgIndex = 0;
|
|
this->setPixmap(*images.at(imgIndex));
|
|
imgIndex++;
|
|
}
|