1018hw

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //窗口名
    this->setWindowTitle("QQ");
    this->setWindowIcon(QIcon(":/01login/icon/kun.webp"));
    this->setFixedSize(480,400);
    QMovie *kk=new QMovie(":/01login/icon/dance.gif");
    ui->logo_label->setMovie(kk);
    kk->start();
    ui->logo_label->setScaledContents(true);
    //账号密码图标
    ui->host_label->setPixmap(QPixmap(":/01login/icon/zhanghu.png"));
    ui->host_label->setScaledContents(true);
    ui->passwd_label->setPixmap(QPixmap(":/01login/icon/passwd.jpg"));
    ui->passwd_label->setScaledContents(true);
    //账号密码写入
    ui->host_edit->setPlaceholderText("账号");
    ui->passwd_edit->setPlaceholderText("密码");
    //qt5连接
    connect(ui->login_btn,&QPushButton::clicked,this,&MainWindow::login_slot);
}
void MainWindow::login_slot()
{
    QString usrname = ui->host_edit->text();
    QString pwd = ui->passwd_edit->text();
    if(usrname=="admin"&&pwd=="123456")
    {
        qDebug()<< "login success";
        this -> close();
    }
    else
    {
        qDebug()<< "login defeat";
        ui -> passwd_edit->clear();
    }
}
MainWindow::~MainWindow()
{
    delete ui;

}

你可能感兴趣的:(命令模式)