1.9.。。

1

有道云笔记

2

.cpp

#include "mywidget.h"
#include "ui_mywidget.h"

myWidget::myWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::myWidget)
{
    ui->setupUi(this);

    this->setWindowTitle("原神");
    this->setStyleSheet("background-color:rgb(70,120,180)");

    ui->lab1->setPixmap(QPixmap(":/picture/pic2.jpg"));
    ui->lab1->setScaledContents(true);

    ui->lab2->setPixmap(QPixmap(":/picture/pic1.jpg"));
    ui->lab2->setScaledContents(true);

    ui->lab3->setPixmap(QPixmap(":/picture/pic3.jpg"));
    ui->lab3->setScaledContents(true);

    ui->edit1->setPlaceholderText("账号/手机/邮箱");

    ui->edit2->setPlaceholderText("密码");
    ui->edit2->setEchoMode(QLineEdit::Password);


    connect(ui->btn2,SIGNAL(clicked()),this,SLOT(close()));

    connect(ui->btn1,&QPushButton::clicked,this,&myWidget::btn1_slot);

}

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

void myWidget::btn1_slot()
{
    if(ui->edit1->text()=="admin" || ui->edit2->text()=="123456")
    {
        qDebug() << "登陆成功" ;
       this->close();
    }
    else
    {
     qDebug() << "登陆失败";
      ui->edit1->clear();
      ui->edit2->clear();
    }

}

.h

#ifndef MYWIDGET_H
#define MYWIDGET_H

#include 
#include  


namespace Ui {
class myWidget;
}

class myWidget : public QWidget
{
    Q_OBJECT

public:
    explicit myWidget(QWidget *parent = nullptr);
    ~myWidget();

private:
    Ui::myWidget *ui;

 public slots:
    void btn1_slot();
};

#endif // MYWIDGET_H

1.9.。。_第1张图片

1.9.。。_第2张图片

你可能感兴趣的:(笔记)