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();
    }
}
相关推荐
阿里嘎多学长3 小时前
2026-05-30 GitHub 热点项目精选
开发语言·程序员·github·代码托管
wapicn993 小时前
API接口调试笔记:从注册到第一个数据返回,全流程详解
java·开发语言·python·lua
.千余3 小时前
【Linux】 TCP进阶详解:字节流、粘包问题、异常情况与UDP完整对比2
linux·运维·c语言·开发语言·经验分享·笔记·php
geovindu3 小时前
python: Bounded Parallelism Pattern
开发语言·python·设计模式·有界并行模式
大明者省3 小时前
Ubuntu Python 部署终极版教程
开发语言·python·ubuntu
光影少年3 小时前
Redux Toolkit 用法、解决原生Redux 冗余问题
开发语言·前端·javascript·react.js·中间件·前端框架·ecmascript
KANGBboy3 小时前
java知识二(数组)
java·开发语言·python
零陵上将军_xdr3 小时前
后端转全栈学习-Day3-JavaScript 基础-1
开发语言·javascript·学习
llilay3 小时前
企业级FastAPI后端模板搭建(二)整合路由Router
开发语言·python·fastapi
不会C语言的男孩3 小时前
C++ Primer Plus 第13章:类继承
开发语言·c++