槽函数
private slots:
void on_comboBox_currentIndexChanged(const QString &arg1);
private:
Ui::Widget *ui;
QTimer timer;
Widget.cpp
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
ui->timeEdit->setTime(QTime::currentTime());
ui->dateEdit->setDate(QDate::currentDate());
ui->dateTimeEdit->setDateTime(QDateTime::currentDateTime());
ui->progressBar->setValue(100);
connect(&timer, &QTimer::timeout,
[this](){
static int i = 0;
i++;
ui->lcdNumber->display(i);
int v = ui->progressBar->value();
v -= 20;
ui->progressBar->setValue(v);
if (v == 0)
timer.stop();
});
timer.start(1000);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_comboBox_currentIndexChanged(const QString &arg1)
{
if (arg1 == "第一题")
ui->textEdit->setText("第一题");
else if (arg1 == "第二题")
ui->textEdit->setText("第二题");
else if (arg1 == "第三题")
ui->textEdit->setText("第三题");
}