#ifndef PICTURE_H
#define PICTURE_H
#include <QWidget>
#include <QLabel>
#include <QPixmap>
#include <QTimer>
#include <QString>
class Picture : public QWidget
{
Q_OBJECT
public:
Picture(QWidget *parent = nullptr);
~Picture();
private:
QLabel* imglabel;
QPixmap* pm;
QTimer* timer;
int cycle;
private slots:
void myfunc();
};
#endif // PICTURE_H
#include "picture.h"
Picture::Picture(QWidget *parent)
: QWidget(parent)
{
cycle = 0;
imglabel = new QLabel(this);
pm = new QPixmap();
imglabel->setGeometry(100,100,700,300);
imglabel->setScaledContents(true);
imglabel->setStyleSheet("border:1px solid red");
myfunc();
timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(myfunc()));
timer->start(1000);
}
Picture::~Picture()
{
}
void Picture::myfunc()
{
cycle = cycle%4;
pm->load(":/src/"+QString::number(cycle)+".png");
imglabel->setPixmap(*pm);
cycle = cycle+1;
}