21,466
社区成员
发帖
与我相关
我的任务
分享


#include "dialog.h"
#include "ui_dialog.h"
#include <QTimer>
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
pix=QPixmap("./res/e.jpg");
ui->label->setScaledContents(true);
ui->label->setPixmap(pix);
timer=new QTimer(this);
timer->setInterval(50);
connect(timer,SIGNAL(timeout()),this,SLOT(onTimer()));
angle=0;
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::on_pushButton_clicked()
{
if(timer->isActive())
timer->stop();
else
timer->start();
}
void Dialog::onTimer()
{
angle+=2;
angle%=360;
QMatrix matrix;
matrix.rotate(angle);
QPixmap rpix;
rpix=pix.transformed(matrix);
ui->label->setPixmap(rpix);
}