#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
setWindowIcon(QIcon(":/pictures/q3.png"));
setWindowTitle("QQ登录");
setWindowFlag(Qt::FramelessWindowHint);
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(my_slot()));
connect(ui->loginButton, &QPushButton::clicked, this, &Widget::my_login_slot);
}
Widget::~Widget()
{
delete ui;
}
void Widget::my_login_slot()
{
if (ui->userNameLineEdit->text() == "admin" && ui->passWdLineEdit->text() == "123456")
{
QMessageBox login(QMessageBox::Information, "登录对话框", "登陆成功", QMessageBox::Ok, this);
login.exec();
emit my_jump();
this->close();
}
else
{
int ret = QMessageBox::critical(this, "错误对话框", "账号和密码不匹配,是否重新输入", QMessageBox::Yes
| QMessageBox::No);
switch(ret)
{
case QMessageBox::Yes: ui->passWdLineEdit->clear(); break;
case QMessageBox::No: this->close(); break;
}
}
}
void Widget::my_slot()
{
int ret = QMessageBox::question(this, "问题对话框", "您是否确定要退出登录?", QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes)
{
this->close();
}
}

- 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
思维导图
