QT DAY3

//源文件
#include "widget.h"
#include "ui_widget.h"
 
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
 
    ui->setupUi(this);
    //设置窗口标题
    this->setWindowTitle("EXVS");
    this->setWindowIcon(QIcon(":/new/prefix1/.png"));
    QLabel *lab1 = new QLabel(this);
    lab1->resize(400, 157);
    lab1->setStyleSheet("background-color:pink");

    //设置动图
    QMovie *mv = new QMovie(":/new/prefix1/bili_v_1699873038780.gif");
    //将动图放进lab1中
    lab1->setMovie(mv);
    mv->start();
    //将动图自动适应lab
    lab1->setScaledContents(true);
    //loge_lab设置图片
    ui->logo_lab->setPixmap(QPixmap(":/new/prefix1/qqlogo.png"));
    ui->logo_lab->setScaledContents(true);
    //隐藏标题栏
    this->setWindowFlag(Qt::FramelessWindowHint);
 
    //设置name_in_edi占位
    ui->name_in_edi->setPlaceholderText("账号/手机/邮箱");
    ui->passwd_in_edi->setPlaceholderText("密码");
    ui->passwd_in_edi->setEchoMode(QLineEdit::Password);
    //设置name_logo_lab设置图片
    ui->name_logo_lab->setPixmap(QPixmap(":/tupian/namelogo.png"));
    ui->name_logo_lab->setScaledContents(true);
 
    //设置passwd_logo_lab设置图片
    ui->passwd_logo_lab->setPixmap(QPixmap(":/tupian/passwdlogo.png"));
    ui->passwd_logo_lab->setScaledContents(true);
 
    //设置login_lab底色
    ui->login_bon->setStyleSheet("background-color: rgb(7,188,252);border-radius: 10px");
 
    //设置erwei_lab图片
    ui->erwei_lab->setPixmap(QPixmap(":/new/prefix1/erwei.png"));
    ui->erwei_lab->setScaledContents(true);
    //设置close_bon为透明
    ui->close_bon->setStyleSheet("background-color: transparent");
    //设置mini_bon为透明
    ui->mini_bon->setStyleSheet("background-color:transparent");
 
 
 
 
 
 
 
}
 
Widget::~Widget()
{
    delete ui;
}
 
//close_bon关闭
void Widget::on_close_bon_clicked()
{
    int res=QMessageBox::question(this,"正在退出","点击 Yes 退出登录,是否退出?");
    if(res==QMessageBox::Yes)
    {
        this->close();
    }
}
//mini_bon窗口最小化
void Widget::on_mini_bon_clicked()
{
    this->showMinimized();
}
 
//登录按钮
void Widget::on_login_bon_clicked()
{
    if(ui->name_in_edi->text()=="admin" && ui->passwd_in_edi->text()=="1234567")
    {
        //跳转窗口
        QMessageBox::information(this,"正在登录","登录成功");
        this->close();
        sleep(1);
 
        emit this->jump_secend();
 
    }
    else
    {
        int res=QMessageBox::warning(this,"错误","账号或密码错误,是否重新输入",QMessageBox::Yes | QMessageBox::No);
        if(res==QMessageBox::No)
        {
            this->close();
        }
        else
        {
            ui->name_in_edi->setText("");
            ui->passwd_in_edi->setText("");
        }
 
    }
 
}
/*************************头文件*******************/
#ifndef WIDGET_H
#define WIDGET_H
 
#include 
#include 
#include 
#include 
 
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE
 
class Widget : public QWidget
{
    Q_OBJECT
 
public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
signals:
    void jump_secend();
 
private slots:
    void on_close_bon_clicked();
 
    void on_mini_bon_clicked();
 
    void on_login_bon_clicked();
 
private:
    Ui::Widget *ui;
};
#endif // WIDGET_H

QT DAY3_第1张图片

你可能感兴趣的:(qt,命令模式,开发语言)