赞
踩
如果账号和密码匹配,则弹出信息对话框,给出提示”登录成功“,提供一个Ok按钮,用户点击Ok后,关闭登录界面,跳转到其他界面
如果账号和密码不匹配,弹出错误对话框,给出信息”账号和密码不匹配,是否重新登录“,并提供两个按钮Yes|No,用户点击Yes后,清除密码框中的内容,继续让用户进行登录,如果用户点击No按钮,则直接关闭登录界面
如果用户点击取消按钮,则弹出一个问题对话框,给出信息”您是否确定要退出登录?“,并给出两个按钮Yes|No,用户点击Yes后,关闭登录界面,用户点击No后,关闭对话框,继续执行登录功能
- #ifndef WIDGET_H
- #define WIDGET_H
-
- #include <QWidget>
- #include <QTextToSpeech>
- #include <QDebug>
- #include <QMessageBox>
- QT_BEGIN_NAMESPACE
- namespace Ui { class Widget; }
- QT_END_NAMESPACE
-
- class Widget : public QWidget
- {
- Q_OBJECT
-
- public:
- Widget(QWidget *parent = nullptr);
- ~Widget();
- signals:
- void Log_in();
- private slots:
- void on_pushButton2_clicked();
-
- void PushbuttonClicked();
-
- private:
- Ui::Widget *ui;
-
- QTextToSpeech *speaker;
- };
- #endif // WIDGET_H
- #include "widget.h"
- #include "ui_widget.h"
-
- Widget::Widget(QWidget *parent)
- : QWidget(parent)
- , ui(new Ui::Widget)
- ,speaker(new QTextToSpeech(this))
- {
- ui->setupUi(this);
- this->setWindowFlag(Qt::FramelessWindowHint);
-
- this->setAttribute(Qt::WA_TranslucentBackground);
- connect(ui->pushButton_2,SIGNAL(clicked()),this,SLOT(on_pushButton2_clicked()));
- connect(ui->pushButton,&QPushButton::clicked,this,&Widget::PushbuttonClicked);
- }
-
- Widget::~Widget()
- {
- delete ui;
- }
-
-
- void Widget::on_pushButton2_clicked()
- {
- int ret = QMessageBox::question(this, "提示", "你真的启不动吗?", QMessageBox::Yes | QMessageBox::No);
-
-
- //根据用户选中的按钮,执行不同的功能
- if(ret == QMessageBox::Yes)
- {
- this->close();
- }
- else
- {
-
- }
- }
-
- void Widget::PushbuttonClicked()
- {
- speaker->say(ui->pushButton->text());
- this->close();
- emit Log_in();
- }
- #ifndef LOGING_H
- #define LOGING_H
-
- #include <QWidget>
- #include <QDebug>
- #include <QMessageBox>
- namespace Ui {
- class Loging;
- }
-
- class Loging : public QWidget
- {
- Q_OBJECT
-
- public:
- explicit Loging(QWidget *parent = nullptr);
- ~Loging();
- signals:
- void Loged1();
-
- public slots:
- void Log_rec();
- private slots:
- void on_pushButton_clicked();
-
- private:
- Ui::Loging *ui;
- };
-
- #endif // LOGING_H
- #include "loging.h"
- #include "ui_loging.h"
-
- Loging::Loging(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::Loging)
- {
-
- ui->setupUi(this);
- this->setWindowFlag(Qt::FramelessWindowHint);
-
- this->setAttribute(Qt::WA_TranslucentBackground);
- ui->lineEdit->setPlaceholderText("支持QQ号/邮箱/手机号登录");
- ui->lineEdit_2->setPlaceholderText("请输入密码");
- ui->lineEdit_2->setEchoMode(QLineEdit::Password);
-
- }
-
- Loging::~Loging()
- {
- delete ui;
-
- }
-
-
-
- void Loging::Log_rec()
- {
- this->show();
- }
-
- void Loging::on_pushButton_clicked()
- {
- if(QString(ui->lineEdit->text())=="admin")
- {
- if(QString(ui->lineEdit_2->text())=="123456")
- {
- QMessageBox msg(QMessageBox::Information, "提示", "登录成功", QMessageBox::Ok, this);
- int ret = msg.exec();
- if(ret == QMessageBox::Ok)
- {
- this->close();
- emit Loged1();
- qDebug() << "4 called";
- }
- }
- else
- {
- int ret = QMessageBox::question(this, "提示", "账号或密码错误,是否重新登录", QMessageBox::Yes | QMessageBox::No);
-
-
- //根据用户选中的按钮,执行不同的功能
- if(ret == QMessageBox::Yes)
- {
- ui->lineEdit_2->clear();
- }
- else
- {
- this->close();
- }
- }
- }
- else
- {
- int ret = QMessageBox::question(this, "提示", "账号或密码错误,是否重新登录", QMessageBox::Yes | QMessageBox::No);
-
-
- //根据用户选中的按钮,执行不同的功能
- if(ret == QMessageBox::Yes)
- {
- ui->lineEdit_2->clear();
- }
- else
- {
- this->close();
- }
- }
- }
- #ifndef INFOR_H
- #define INFOR_H
-
- #include <QWidget>
- #include <QDebug>
- namespace Ui {
- class infor;
- }
-
- class infor : public QWidget
- {
- Q_OBJECT
-
- public:
- explicit infor(QWidget *parent = nullptr);
- ~infor();
- public slots:
- void Loged_rec1();
-
- public slots:
- void push_close();
- private:
- Ui::infor *ui;
- };
-
- #endif // INFOR_H
- #include "infor.h"
- #include "ui_infor.h"
-
- infor::infor(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::infor)
- {
- ui->setupUi(this);
- this->setWindowFlag(Qt::FramelessWindowHint);
- this->setAttribute(Qt::WA_TranslucentBackground);
- connect(ui->pushButton,&QPushButton::clicked,this,&infor::push_close);
- }
-
- infor::~infor()
- {
- delete ui;
- }
-
- void infor::Loged_rec1()
- {
- qDebug() << "1 called";
- ui->label_2->setText("登陆成功!正在加载请稍后...");
- this->show();
- }
-
-
- void infor::push_close()
- {
- qDebug() << "3 called";
- this->close();
- }
-
-
登录第三版
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。