01.09

01.09_第1张图片

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

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->lable1->setPixmap(QPixmap("D:\\C++andQT\\Qt\\0109_3text\\pictrue\\steam2.png"));
    this->ui->lable1->setScaledContents(true);

    ui->label_2->setPixmap(QPixmap("D:\\C++andQT\\Qt\\0109_3text\\pictrue\\userName.jpg"));
    this->ui->label_2->setScaledContents(true);

    ui->label_3->setPixmap(QPixmap("D:\\C++andQT\\Qt\\0109_3text\\pictrue\\passwd.jpg"));
     this->ui->label_3->setScaledContents(true);

    ui->lineEdit2->setEchoMode(QLineEdit::Password);

    //qt4
    btn2=new QPushButton("取消",this);
    btn2->move(ui->Button1->x()+ui->Button1->width()+20,ui->Button1->y());
    btn2->resize(ui->Button1->width(),ui->Button1->height());
    connect(btn2,SIGNAL(clicked()),this,SLOT(close()));
    //qt5
    connect(ui->Button1,&QPushButton::clicked,this,&Widget::Button1_slot);

}

Widget::~Widget()
{
    delete ui;
}
void Widget::Button1_slot(){
    if(ui->lineEdit1->text()=="sujianrui"&&ui->lineEdit2->text()=="123456"){
        qDebug()<<"登录成功";
        this->close();
    }else {
    qDebug()<<"登录失败";
    ui->lineEdit2->setText("");
}
}

01.09_第2张图片01.09_第3张图片

你可能感兴趣的:(作业,程序人生)