01.09

2024-01-09 21:43:46

#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("");
}
}

文章来源:https://blog.csdn.net/Sujianrui/article/details/135488257
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。