网站型跟商城型,关于教育网站的策划书,网站建设初级工程师,上海环球金融中心大厦简介完善对话框#xff0c;点击登录弹出对话框#xff0c;如果账号和密码匹配#xff0c;则弹出信息对话框#xff0c;给出提示”登录成功“#xff0c;提供一个Ok按钮#xff0c;用户点击Ok后#xff0c;关闭登录界面#xff0c;跳转到其他界面
如果账号和密码不匹配点击登录弹出对话框如果账号和密码匹配则弹出信息对话框给出提示”登录成功“提供一个Ok按钮用户点击Ok后关闭登录界面跳转到其他界面
如果账号和密码不匹配弹出错误对话框给出信息”账号和密码不匹配是否重新登录“,并提供两个按钮Yes|No用户点击Yes后清除密码框中的内容继续让用户进行登录如果用户点击No按钮则直接关闭登录界面
如果用户点击取消按钮则弹出一个问题对话框给出信息”您是否确定要退出登录“并给出两个按钮Yes|No用户迪纳基Yes后关闭登录界面用户点击No后关闭对话框继续执行登录功能
要求基于属性版实现、基于静态成员函数实现 两个种方式都要有
#include widget.h
#include ui_widget.h
#include QDebug
Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui-setupUi(this);this-setWindowFlag(Qt::FramelessWindowHint);this-setAttribute(Qt::WA_TranslucentBackground);QObject::connect(ui-pushButton_2,SIGNAL(clicked()),this,SLOT(btn_closed()));QObject::connect(ui-pushButton_3,SIGNAL(clicked()),this,SLOT(btn_hide()));
}Widget::~Widget()
{delete ui;
}void Widget::btn_closed()
{//基于函数成员的版本int retQMessageBox::information(this,提示,您是否确定要退出登录,QMessageBox::Yes | QMessageBox::No,QMessageBox::No);//根据用户的选择执行不同的功能if(retQMessageBox::Yes){this-close();}
}
void Widget::btn_hide()
{this-showMinimized();
}
void Widget::on_pushButton_clicked()
{if(ui-lineEdit-text() admin ui-lineEdit_2-text() 12345){ui-label_3-setStyleSheet(QString(background-color:blue;color:white));ui-label_3-setText(登陆成功);//基于属性版本QMessageBox msg(QMessageBox::Information,提示,登录成功,QMessageBox::Ok,this);//调用exrc弹出对话框int retmsg.exec();//根据用户的选择 执行不同的功能if(retQMessageBox::Ok){qDebug() 登录成功 ;}else{qDebug() 登录失败;}// 使用 QTimer 延时关闭QTimer::singleShot(600, this, [this](){emit log_sig();ui-label_3-setStyleSheet(QString(background:transparent;));this-close();});}else{ui-label_3-setText(登陆失败);ui-label_3-setStyleSheet(QString(background-color:red;color:black));//基于静态成员函数版本int retQMessageBox::critical(this,错误,账号密码不正确,是否重新登录,QMessageBox::Yes | QMessageBox::No,QMessageBox::No);//根据用户的选择执行不同的功能if(retQMessageBox::Yes){ui-lineEdit_2-clear();}else{this-close();}// 使用 QTimer 延时清除文本QTimer::singleShot(600, this, [this](){ui-label_3-setStyleSheet(QString(background:transparent;));ui-label_3-setText();ui-lineEdit_2-setText();});}
}ui部分 效果图