思维导图
使用手动连接,将登录框中的取消按钮使用qt4版本的连接到自定义的槽函数中,在自定义的槽函数中调用关闭函数
将登录按钮使用qt5版本的连接到自定义的槽函数中,在槽函数中判断ui界面上输入的账号是否为"admin",密码是否为"123456",如果账号密码匹配成功,则输出“登录成功”,并关闭该界面,如果匹配失败,则输出登录失败,并将密码框中的内容清空
#include "ui_wwwww.h"wwwww::wwwww(QWidget *parent): QMainWindow(parent), ui(new Ui::wwwww)
{ui->setupUi(this);ui->lape->setStyleSheet("border-image:url(D:/shar/pictrue/111.jpg)");ui->lape->setScaledContents(true);ui->tu1->setPixmap(QPixmap("D:/shar/pictrue/1.jpg"));ui->tu1->setScaledContents(true);ui->tu2->setPixmap(QPixmap("D:/shar/pictrue/2.jpg"));ui->tu2->setScaledContents(true);//qt4connectconnect(ui->bth2,SIGNAL(clicked()),this,SLOT(close()));connect(ui->bth1,&QPushButton::clicked,this,&wwwww::my_slot);ui->username->setText("账号");ui->username->setScaledContents(true);ui->password->setText("密码");ui->password->setScaledContents(true);
}wwwww::~wwwww()
{delete ui;
}void wwwww::my_slot()
{if(ui->lin1->text()=="admin"&&ui->lin2->text()=="123456"){qDebug()<<"登录成功";}else{qDebug()<<"登陆失败";ui->lin1->clear();ui->lin2->clear();}
}void wwwww::on_bth2_clicked()
{}void wwwww::on_bth1_clicked()
{}