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();
    }
}
相关推荐
想胖的壮壮5 分钟前
python中的原子操作简介
开发语言·python
爱吃香菜¹6 分钟前
深入理解【 String类】
java·开发语言
LeoLei806021 分钟前
新特性之C++17
开发语言·c++
码农超哥同学29 分钟前
Python面试题:如何在 Python 中反转一个字符串?
开发语言·windows·python·面试·编程
不死鸟.亚历山大.狼崽子1 小时前
python库(2):Passlib库
开发语言·python
jllws11 小时前
C++基础:STL概述
开发语言·c++
FightingLod1 小时前
C++中list容器使用详解
开发语言·c++·list
Zucker n1 小时前
学会python——用python制作一个登录和注册窗口(python实例十八)
开发语言·python
mana飞侠1 小时前
代码随想录算法训练营第59天:动态[1]
开发语言·数据结构·算法·动态规划
艾恩小灰灰1 小时前
为何Web前端开发仍坚守 HTML 和 CSS,而不全然拥抱纯 JavaScript?
开发语言·前端·javascript·css·html·纯js