一、思维导图
二、练习
#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);
}Widget::~Widget()
{delete ui;
}void Widget::on_login_btn_clicked()
{if(ui->id_edit->text() == "kkk" && ui->passwd_edit->text() == "123456"){QMessageBox::information(this,"info","登录成功",QMessageBox::Yes);this->close();}else{int ret = QMessageBox::critical(this,"wrong","账号密码错误,是否重新登陆?",QMessageBox::Yes | QMessageBox::No);if(ret == QMessageBox::Yes){ui->passwd_edit->clear();ui->id_edit->clear();}else if(ret == QMessageBox::No){this->close();}}
}void Widget::on_exit_btn_clicked()
{int ret = QMessageBox::question(this, "question", "是否确定退出登录?", QMessageBox::Yes | QMessageBox::No);if(ret == QMessageBox::Yes){close();}
}