Qtday2

#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    //窗口设置
    ui->setupUi(this);
    this->setWindowTitle("原神");
    this->setWindowIcon(QIcon(":/picture/genshin.png"));
    this->setWindowFlag(Qt::FramelessWindowHint);

    //标签设置
    QMovie *mv = new QMovie(":/picture/leishen.gif");
    ui->lab1->setMovie(mv);
    mv->start();

    ui->namelab->setPixmap(QPixmap(":/picture/OIP-C.jpg"));
    ui->namelab->resize(30, 30);
    ui->namelab->move(ui->naedt->x()-35, ui->naedt->y());
    ui->namelab->setScaledContents(true);

    ui->pwdlab->setPixmap(QPixmap(":/picture/suo.jpg"));
    ui->pwdlab->resize(30, 30);
    ui->pwdlab->move(ui->pwdedt->x()-35, ui->pwdedt->y());
    ui->pwdlab->setScaledContents(true);

    ui->naedt->setPlaceholderText("账号/电话/邮箱");
    ui->pwdedt->setPlaceholderText("密码");

    //按钮设置
    this->connect(ui->btn2, SIGNAL(clicked()), this, SLOT(close())); //按取消关闭窗口
    connect(ui->btn1, &QPushButton::clicked, this, &Widget::my_slot);



}

Widget::~Widget()
{
    delete ui;
}

void Widget::my_slot()
{
    if("admin" == ui->naedt->text())
    {
        if("123456" == ui->pwdedt->text())
        {
            qDebug() << "登录成功";
            this->close();
        }
    }
    else
    {
        qDebug() << "登陆失败";
        ui->pwdedt->clear();
    }
}

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