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();
    }
}
相关推荐
蜗牛沐雨11 分钟前
Rust 中的 Pin 和 Unpin:内存安全与异步编程的守护者
服务器·开发语言·rust
python算法(魔法师版)28 分钟前
JavaScript性能优化实战,从理论到落地的全面指南
开发语言·性能优化·前端框架·代理模式
shmily麻瓜小菜鸡37 分钟前
vue3使用tailwindcss报错问题
开发语言·前端·javascript·vue.js
studyer_domi1 小时前
Matlab 车辆四自由度垂向模型平稳性
开发语言·matlab·汽车
passionSnail1 小时前
《用MATLAB玩转游戏开发:从零开始打造你的数字乐园》基础篇(2D图形交互)-《打砖块:向量反射与实时物理模拟》MATLAB教程
开发语言·matlab·交互
Themberfue2 小时前
RabbitMQ ②-工作模式
开发语言·分布式·后端·rabbitmq
在下小孙2 小时前
Lua—元表(Metatable)
开发语言·lua·元表
Yuze_Neko2 小时前
C#异步Task,await,async和Unity同步协程
开发语言·unity·c#
努力的小帅2 小时前
c++——二叉树进阶
开发语言·数据结构·c++·学习·算法·面试
俺不是西瓜太郎´•ﻌ•`3 小时前
二维差分数组(JAVA)蓝桥杯
java·开发语言·蓝桥杯