思路:设置个定时器,每隔一段时间,更新背景图片
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
qTimer1 = new QTimer(this);
//QObject::connect(qTimer1,SIGNAL(timeout()),this,SLOT(refreshBtn()));
QObject::connect(qTimer1,&QTimer::timeout,this,&MainWindow::refreshBtn);
qTimer1->start(200);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::refreshBtn()
{
static int count = 1;
if(count>6)
count = 1;
QString szStyle = "QPushButton#moveBtn{border:0px;background-image:url(:/images/zhuanhuan%d.png);}";
szStyle.replace("%d",QString::number(count));
ui->moveBtn->setStyleSheet(szStyle);
count++;
}