You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.0 KiB
52 lines
1.0 KiB
#include "mainwindow.h"
|
|
#include "ui_mainwindow.h"
|
|
#include <QPixmap>
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
|
QMainWindow(parent),
|
|
ui(new Ui::MainWindow)
|
|
{
|
|
ui->setupUi(this);
|
|
MainWindow::setWindowTitle(tr("钢琴块儿"));
|
|
connect(ui->widget,&TestWidget::value,this,[=](int value){
|
|
ui->label->setText(QString::number(value));
|
|
});
|
|
timer= new QTimer(this);
|
|
connect(timer, &QTimer::timeout, this, &MainWindow::timeoutSlot);
|
|
|
|
}
|
|
|
|
MainWindow::~MainWindow()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void MainWindow::on_pushButton_clicked()
|
|
{
|
|
timer->start(500);//ms
|
|
ui->widget->start();
|
|
ui->widget->setFocus();
|
|
}
|
|
|
|
void MainWindow::on_pushButton_2_clicked()
|
|
{
|
|
timer->start(500);//ms
|
|
ui->widget->restart();
|
|
ui->widget->setFocus();
|
|
}
|
|
void MainWindow::timeoutSlot()
|
|
{
|
|
static int tmpe=0;
|
|
|
|
if(tmpe==0)
|
|
{
|
|
ui->label_4->setPixmap(QPixmap(":/image/image/monster2.png"));
|
|
tmpe=1;
|
|
}
|
|
else
|
|
{
|
|
ui->label_4->setPixmap(QPixmap(":/image/image/monster1.png"));
|
|
tmpe=0;
|
|
}
|
|
}
|