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();
    }
}
相关推荐
ch.ju21 分钟前
Java—idea知识:如何创建新项目
java·开发语言·intellij-idea
Evand J32 分钟前
【MATLAB例程,图像滤波降噪12】加权中值滑动窗口滤波(WMF)图像降噪,包含滤波质量评价。附代码下载链接
开发语言·图像处理·人工智能·计算机视觉·matlab·滑动窗口·滤波
Tairitsu_H36 分钟前
[C++] C++11类和STL的新特性
开发语言·c++·stl·c++11
承渊政道40 分钟前
Python IDLE鸿蒙PC适配全记录:从Tkinter桌面程序到ArkUI原生开发闭环
开发语言·python·harmonyos·鸿蒙系统·桌面程序
YMWM_1 小时前
查看realsense相机序列号脚本
开发语言·python·数码相机
传奇开心果编程1 小时前
【dioxus0.7基础语法学与练】第8课:RSX 宏 — Dioxus 声明式 UI 语法
开发语言·学习·rust
wuyk5552 小时前
18.Kruskal 算法:用最短的边连成一张网
开发语言·算法·图论
Evand J2 小时前
【MATLAB例程,图像降噪7】高斯加权滑动窗口滤波,用于图像降噪,带质量评价,附代码下载链接
开发语言·图像处理·matlab·滑动窗口·滤波·降噪·图像滤波
十年一梦惊觉醒2 小时前
快手视频发布助手,全自动视频发布带货工具
开发语言·前端·javascript
Java后端的Ai之路2 小时前
一文搞懂 GitHub Actions-CICD
开发语言·大模型·github·cicd·action