#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);//去掉头部this->setWindowFlag(Qt::FramelessWindowHint);//去掉空白this->setAttribute(Qt::WA_TranslucentBackground);//登录界面取消按钮 收到连接信号和自定义槽函数,基于qt4版本connect(ui->Btn2,SIGNAL(clicked()),this,SLOT(my_solt()));//登录界面实现connect(ui->Btn1,SIGNAL(clicked()),this,SLOT(Btn1_solt()));
}Widget::~Widget()
{delete ui;
}
//触发自定义槽函数实现取消界面
void Widget::my_solt()
{//弹出提示问题图标对话框QMessageBox msg(QMessageBox::Question,"提示","您确定要退出登录?",QMessageBox::Yes |QMessageBox::No,this);//调用exec()弹出对话框int ret = msg.exec();if(ret==QMessageBox::Yes){//关闭窗口this->close();}
}//自定义登录槽函数
void Widget::Btn1_solt()
{//判断账号密码是否正确if(ui->Edit1->text()== "admin" && ui->Edit2->text()== "123456"){//弹出信息对话框QMessageBox msg(QMessageBox::Information, "提示" , "登录成功",QMessageBox::Ok);int ret = msg.exec();if(ret == QMessageBox::Ok){this->close(); //关闭界面emit my_jump(); //触发第二个界面的信号}}else {QMessageBox msg(QMessageBox::Critical, "错误" , "账号和密码不匹配。是否重新登录?" ,QMessageBox::Yes |QMessageBox::No,this);int ret = msg.exec();if(ret == QMessageBox::Yes){//清空密码和账号信息ui->Edit1->text().clear();ui->Edit2->text().clear();}else{this->close();
}}
}