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();
    }
}
相关推荐
阿凡达蘑菇灯4 分钟前
langgraph---条件边
开发语言·前端·javascript
Han.miracle13 分钟前
Java的多线程——多线程(3)线程安全
java·开发语言·jvm·学习·安全·线程·多线程
周杰伦_Jay33 分钟前
【主流开发语言深度对比】Python/Go/Java/JS/Rust/C++评测
开发语言·python·golang
ldmd28439 分钟前
Go语言实战:入门篇-5:函数、服务接口和Swagger UI
开发语言·后端·golang
光子物联单片机1 小时前
C语言基础开发入门系列(八)C语言指针的理解与实战
c语言·开发语言·stm32·单片机·mcu
是苏浙1 小时前
零基础入门C语言之文件操作
c语言·开发语言
盈电智控1 小时前
体力劳动反而更难被AI取代?物联网科技如何守护最后的劳动阵地
开发语言·人工智能·python
隔壁阿布都1 小时前
Spring Boot中的Optional如何使用
开发语言·spring boot·python
小龙报1 小时前
《C语言疑难点 --- C语内存函数专题》
c语言·开发语言·c++·创业创新·学习方法·业界资讯·visual studio
国服第二切图仔2 小时前
Rust开发实战之简单游戏开发(piston游戏引擎)
开发语言·rust·游戏引擎