#include "frmselectdoor.h" #include "ui_frmselectdoor.h" #include "head.h" frmSelectDoor::frmSelectDoor(QWidget *parent) : QWidget(parent), ui(new Ui::frmSelectDoor) { ui->setupUi(this); this->initForm(); } frmSelectDoor::~frmSelectDoor() { delete ui; } void frmSelectDoor::showEvent(QShowEvent *) { useSec = 0; timer->start(); } void frmSelectDoor::initForm() { doorIndex = 0; doorName << "外门" << "内门1" << "内门2" << "内门3" << "内门4" << "内门5"; ui->labCount->setText(QString("%1 / %2").arg(doorIndex + 1).arg(doorName.count())); useSec = 0; timer = new QTimer(this); timer->setInterval(1000); connect(timer, SIGNAL(timeout()), this, SLOT(changeTime())); } void frmSelectDoor::changeTime() { if (useSec < 60) { useSec++; ui->labSec->setText(QString("剩余操作时间: 00:%1").arg(60 - useSec)); } else { //倒计时结束 } } void frmSelectDoor::on_btnUp_clicked() { if (doorIndex > 0) { doorIndex--; ui->btnDoor->setText(doorName.at(doorIndex)); ui->labCount->setText(QString("%1 / %2").arg(doorIndex + 1).arg(doorName.count())); } } void frmSelectDoor::on_btnDown_clicked() { if (doorIndex < doorName.count() - 1) { doorIndex++; ui->btnDoor->setText(doorName.at(doorIndex)); ui->labCount->setText(QString("%1 / %2").arg(doorIndex + 1).arg(doorName.count())); } } void frmSelectDoor::on_btnDoor_clicked() { if (ui->btnDoor->text() == "外门") { emit returnThis(5); } else { emit returnThis(6); } }