-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput.cpp
59 lines (55 loc) · 1.65 KB
/
input.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include "input.h"
#include "ui_input.h"
input::input(QWidget *parent) :
QWidget(parent),
ui(new Ui::input)
{
ui->setupUi(this);
QRegExp regx("^[0-8]$");
QValidator * qv = new QRegExpValidator(regx);
this->ui->Edit1->setValidator(qv);
this->ui->Edit2->setValidator(qv);
this->ui->Edit3->setValidator(qv);
this->ui->Edit4->setValidator(qv);
this->ui->Edit5->setValidator(qv);
this->ui->Edit6->setValidator(qv);
this->ui->Edit7->setValidator(qv);
this->ui->Edit8->setValidator(qv);
this->ui->Edit9->setValidator(qv);
connect(ui->pushButton,&QPushButton::clicked,this,&input::getNum);
}
input::~input()
{
delete ui;
}
void input::getNum()
{
this->Map[0][0]=this->ui->Edit1->text().toInt();
this->Map[0][1]=this->ui->Edit2->text().toInt();
this->Map[0][2]=this->ui->Edit3->text().toInt();
this->Map[1][0]=this->ui->Edit4->text().toInt();
this->Map[1][1]=this->ui->Edit5->text().toInt();
this->Map[1][2]=this->ui->Edit6->text().toInt();
this->Map[2][0]=this->ui->Edit7->text().toInt();
this->Map[2][1]=this->ui->Edit8->text().toInt();
this->Map[2][2]=this->ui->Edit9->text().toInt();
if(this->check()){
emit this->inputOver();
this->close();
}
else
QMessageBox::critical(this,"critical","输入信息错误,请重新输入");
}
bool input::check()
{
bool judge[9]={0};
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
if(!judge[this->Map[i][j]])
judge[this->Map[i][j]]=true;
else
return false;
}
}
return true;
}