完善对话框,点击登录对话框,如果账号和密码匹配,则弹出信息对话框,给出提示“登录成功",提供一个Ok按钮,用户点击OK后,关闭登录界面,跳转到其他界面
如果账号和密码不匹配,弹出错误对话框,给出信息”账号和密码不匹配,是否重新登录”,并提供两个按钮YesINO,用户点击Yes后,清除密码框中的内容,继续让用户进行登录,如果用户点击No按钮,则直接关闭登录界面
如果用户点击取消按钮,则弹出一个问题对话框,给出信息"您是否确定要退出登录?",并给出两个按钮YeSINO,用户迪纳基Yes后,关闭登录界面,用户点击N0后,关闭对话框,继续执行登录功能要求:基于属性版和基于静态成员函数版至少各用一个
#include "hw20240221.h"
#include "ui_hw20240221.h"hw20240221::hw20240221(QWidget *parent): QWidget(parent), ui(new Ui::hw20240221)
{ui->setupUi(this);/* ---- connect cancel button click action signal to slot:my_BtnCancel_clicked ---- *///connect(ui->BtnCancel,SIGNAL(clicked()),this,SLOT(my_BtnCancel_clicked()));connect(ui->BtnLogin,&QPushButton::clicked,this,&hw20240221::my_BtnLogin_clicked);connect(this,&hw20240221::my_signal,this,&hw20240221::my_signal_slot);setWindowFlag(Qt::FramelessWindowHint);setAttribute(Qt::WA_TranslucentBackground);
}hw20240221::~hw20240221()
{delete ui;
}void hw20240221::my_BtnCancel_clicked(){this->close();
}void hw20240221::my_BtnLogin_clicked(){qDebug() << "my_BtnLogin_clicked";
// emit my_signal();
// QMessageBox msg(QMessageBox::Warning,
// "warning",
// "please wait",
// QMessageBox::Yes|QMessageBox::No,
// this);
// msg.exec();if(ui->EdtUserName->text() == "admin" && ui->EdtPassword->text() == "123456"){int ret = QMessageBox::information(this,"登录成功"," 登录成功 ",QMessageBox::Ok);if(ret == QMessageBox::Ok){}
// int ret = QMessageBox::question(this,"question","are you hungury ?",QMessageBox::Yes | QMessageBox::No);
// if(ret == QMessageBox::Yes){
// QMessageBox::information(this,"info","yes",QMessageBox::Ok);// }}}void hw20240221::my_signal_slot(){if(ui->EdtUserName->text() == "admin" && ui->EdtPassword->text() == "123456"){emit sig_LoginSuc();}else{//qDebug() << "login failed, please re-input";ui->LabResponse->setText("login failed, please re input...");ui->EdtUserName->clear();ui->EdtPassword->clear();}
}void hw20240221::on_LabClear_linkActivated(const QString &link)
{}void hw20240221::on_LabClear_linkHovered(const QString &link)
{}void hw20240221::on_LabCancel_linkActivated(const QString &link)
{}void hw20240221::on_LabCancel_linkHovered(const QString &link)
{}void hw20240221::on_BtnClear_clicked()
{ui->EdtUserName->clear();ui->EdtPassword->clear();
}