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();
    }
}
相关推荐
泡海椒34 分钟前
JQuick-Excel dateFormat 转换实战:日期值与 FORMAT 显示格式的边界
开发语言·python·excel
白杨尚青1 小时前
C++入门篇(十三):vector(上)——动态数组:构造、空间增长与迭代器失效
开发语言·c++·笔记·算法·stl
江江爱编程1 小时前
java零基础保姆级教学01
java·开发语言
沐晓时光1 小时前
C语言入门,深入理解指针(2)
c语言·开发语言
2601_962885721 小时前
如何用 Python 做均线粘合选股?(多头发散前的变盘候选)
开发语言·python
2601_962071572 小时前
类变量和全局变量的隔离性有什么区别?
java·开发语言·jvm
海绵宝宝转agent2 小时前
LeetCode100 LRU缓存思路讲解
java·开发语言·缓存
AC赳赳老秦2 小时前
OpenClaw 与 FineBI 联动方案:公开数据自动采集与实时业务分析看板实践
大数据·开发语言·python·php·finebi·deepseek·openclaw
通信瓦工2 小时前
OCP 冷却环境与冷却剂分配单元(CDU)子项目
java·开发语言
坤坤子吖2 小时前
Python基础语法学习:函数
开发语言·笔记·python·学习