QT——day2

cpp 复制代码
#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    ui->LogoLab->setPixmap(QPixmap(":/pictrue/logo.png"));
    ui->LogoLab->setScaledContents(true);
    ui->UsernameLab->setPixmap(QPixmap(":/pictrue/wodepeizhenshi.png"));
    ui->UsernameLab->setScaledContents(true);
    ui->PasswdLab->setPixmap(QPixmap(":/pictrue/passwd.jpg"));
    ui->PasswdLab->setScaledContents(true);
    ui->PasswdEdit->setEchoMode(QLineEdit::Password);
    connect (ui->LoginBtn,SIGNAL(clicked()),this,SLOT(my_slot()));
}


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


void Widget::on_CancelBtn_clicked()
{
    this->close();
}
void Widget::my_slot()
{
    if(ui->UsernameEdit->text()=="admin" && ui->PasswdEdit->text() == "123456")
    {
        QLabel *Msg1 = new QLabel ("登录成功",this);
        Msg1->move(300,300);
        Msg1->resize(100,30);
        Msg1->setStyleSheet("background-color:red");
        Msg1->show();
        QTimer::singleShot(3000, this, SLOT(close()));
    }else
    {
        QLabel *Msg2 = new QLabel ("登陆失败",this);
        Msg2->move(300,300);
        Msg2->resize(100,30);
        Msg2->setStyleSheet("background-color:red");
        Msg2->show();
        ui->UsernameEdit->clear();
        ui->PasswdEdit->clear();
    }
}
相关推荐
时见先生5 小时前
Python库和conda搭建虚拟环境
开发语言·人工智能·python·自然语言处理·conda
a努力。5 小时前
国家电网Java面试被问:混沌工程在分布式系统中的应用
java·开发语言·数据库·git·mysql·面试·职场和发展
Yvonne爱编码5 小时前
Java 四大内部类全解析:从设计本质到实战应用
java·开发语言·python
wqwqweee5 小时前
Flutter for OpenHarmony 看书管理记录App实战:搜索功能实现
开发语言·javascript·python·flutter·harmonyos
yongui478346 小时前
基于MATLAB的NALM锁模光纤激光器仿真实现
开发语言·matlab
-To be number.wan6 小时前
Python数据分析:numpy数值计算基础
开发语言·python·数据分析
Cx330❀7 小时前
【优选算法必刷100题】第038题(位运算):消失的两个数字
开发语言·c++·算法·leetcode·面试
Loo国昌7 小时前
深入理解 FastAPI:Python高性能API框架的完整指南
开发语言·人工智能·后端·python·langchain·fastapi
hoiii1878 小时前
16APSK/32APSK调制解调MATLAB仿真实现
开发语言·matlab·fpga开发
feifeigo1238 小时前
基于MATLAB的情感语音模板培训与识别实现方案
开发语言·matlab