-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathmainwindow.cpp
72 lines (64 loc) · 1.57 KB
/
mainwindow.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
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->widget->setText("aaaaaa");
ui->widget->setLabelText("用户名");
ui->widget->setTipText("允许大小写字母、数字、下划线");
ui->widget_2->setLabelText("密码");
ui->widget_2->setTipText("任意文字");
ui->widget_2->editor()->setEchoMode(QLineEdit::EchoMode::Password);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_2_clicked()
{
if (ui->widget->editor()->hasFocus())
{
ui->widget->showCorrect();
ui->widget->setMsgText("");
}
else if (ui->widget_2->editor()->hasFocus())
{
ui->widget_2->showCorrect();
ui->widget_2->setMsgText("");
}
}
void MainWindow::on_pushButton_clicked()
{
if (ui->widget->editor()->hasFocus())
{
ui->widget->showWrong("用户名已存在");
}
else if (ui->widget_2->editor()->hasFocus())
{
ui->widget_2->showWrong("密码错误,您还剩余2次机会", true);
}
}
void MainWindow::on_pushButton_3_clicked()
{
if (ui->widget->editor()->hasFocus())
{
ui->widget->showLoading();
}
else if (ui->widget_2->editor()->hasFocus())
{
ui->widget_2->showLoading();
}
}
void MainWindow::on_pushButton_4_clicked()
{
if (ui->widget->editor()->hasFocus())
{
ui->widget->hideLoading();
}
else if (ui->widget_2->editor()->hasFocus())
{
ui->widget_2->hideLoading();
}
}