QT day 2

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

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
  //  this->setFixedSize(585,409);
    this->setWindowTitle("qq");
    this->setWindowIcon(QIcon(":/qw/4.jpg"));
    QMovie *mv = new QMovie(":/qw/88.gif");
    ui->label1->setPixmap(QPixmap(":/qw/88.gif"));
    ui->label1->setScaledContents(true);
    ui->label1->setMovie(mv);
    mv->start();
    ui->label_2->setPixmap(QPixmap(":/qw/4.jpg"));
    ui->label_2->resize(30,30);
    ui->label_2->setScaledContents(true);
    ui->label_3->setPixmap(QPixmap(":/qw/2.png"));
    ui->label_3->resize(30,30);
    ui->label_3->setScaledContents(true);
    ui->lineEdit1->setPlaceholderText("账户/手机号");
    ui->lineEdit_2->setPlaceholderText("密码");
    ui->lineEdit_2->setEchoMode(QLineEdit::Password);
    ui->pushButton1->setStyleSheet("background-color: rgb(85, 170, 255);border-radius:4");
    ui->pushButton_2 ->setStyleSheet("background-color: rgb(85, 170, 255);border-radius:4");
    connect(ui->pushButton_2,SIGNAL(clicked()),this,SLOT(close()));
    connect(this,&Widget::mysignal,[&](){
        if(ui->lineEdit1->text()=="admin")
        {
            if(ui->lineEdit_2->text()=="123456")
            {
                cout << "login success" << endl ;
                this->close();
            }
            else
            {
                cout << "login false" << endl ;
                ui->lineEdit_2->clear();
            }
        }
        else
            cout << "false" << endl;
    });

}

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


void Widget::on_pushButton1_clicked()
{
    emit mysignal();
}

你可能感兴趣的:(c++,qt)