一、思维导图
二、将day1做的登录界面升级优化【资源文件的添加】
三、在登录界面的登录取消按钮进行一下设置
使用手动连接,将登录框中的取消按钮使用qt4版本的连接到自定义的槽函数中,在自定义的槽函数中调用关闭函数
将登录按钮使用qt5版本的连接到自定义的槽函数中,在槽函数中判断ui界面上输入的账号是否为"admin",密码是否为"123456",如果账号密码匹配成功,则输出“登录成功”,并关闭该界面,如果匹配失败,则输出登录失败,并将密码框中的内容清空
头文件
#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>
#include <QMovie>
#include <QDebug>QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACEclass Widget : public QWidget
{Q_OBJECTpublic:Widget(QWidget *parent = nullptr);~Widget();signals: //信号函数void btnSignal();public slots: //槽函数void exitBtnSlot();void loginBtnSlot();private:Ui::Widget *ui;
};
#endif // WIDGET_H
测试文件
#include "widget.h"
#include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{this->setWindowFlag(Qt::FramelessWindowHint); //纯净窗口ui->setupUi(this);QMovie *mv1 = new QMovie(":/resource/A1.gif");QMovie *mv2 = new QMovie(":/resource/A2.gif");QMovie *mv3 = new QMovie(":/resource/A3.gif");QMovie *mv4 = new QMovie(":/resource/A4.gif");QMovie *mv5 = new QMovie(":/resource/A5.gif");ui->pic1->setMovie(mv1);mv1->start();ui->pic2->setMovie(mv2);mv2->start();ui->pic3->setMovie(mv3);mv3->start();ui->pic4->setMovie(mv4);mv4->start();ui->pic5->setMovie(mv5);mv5->start();ui->pic1->setScaledContents(true);ui->pic2->setScaledContents(true);ui->pic3->setScaledContents(true);ui->pic4->setScaledContents(true);ui->pic5->setScaledContents(true);ui->logoLab->setPixmap(QPixmap(":/resource/BlueArchive.png"));ui->logoLab->setScaledContents(true);//手动连接系统信号和自定义槽函数connect(ui->exitBtn,SIGNAL(clicked()),this,SLOT(exitBtnSlot()));connect(ui->loginBtn,&QPushButton::clicked,this,&Widget::loginBtnSlot);/*行编辑器操作*/ui->passWordEdit->setEchoMode(QLineEdit::Password); //设置显示模式ui->userNameEdit->setPlaceholderText("输入用户名"); //设置占位ui->passWordEdit->setPlaceholderText("输入密码");
}Widget::~Widget()
{delete ui;
}void Widget::exitBtnSlot()
{this->close();
}void Widget::loginBtnSlot()
{if(ui->userNameEdit->text() == "Legacystar"){if(ui->passWordEdit->text() == "0d000721"){QMessageBox::information(this, "提示", "登录成功", QMessageBox::Ok);
// qDebug() << "登录成功";this->close();}else if(ui->passWordEdit->text() == ""){QMessageBox::warning(this, "提示", "密码为空", QMessageBox::Ok);
// qDebug() << "密码为空";}else{QMessageBox::critical(this, "提示", "密码错误", QMessageBox::Ok);
// qDebug() << "密码错误";ui->passWordEdit->clear();}}else if(ui->userNameEdit->text() == ""){QMessageBox::warning(this, "提示", "用户名为空", QMessageBox::Ok);
// qDebug() << "用户名为空";}else{QMessageBox::critical(this, "提示", "用户名不存在", QMessageBox::Ok);
// qDebug() << "用户名不存在";ui->userNameEdit->clear();ui->passWordEdit->clear();}
}