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();
    }
}
相关推荐
像风一样的男人@4 分钟前
python --读取psd文件
开发语言·python·深度学习
输出输入6 分钟前
前端核心技术
开发语言·前端
加油,小猿猿6 分钟前
Java开发日志-双数据库事务问题
java·开发语言·数据库
薛定谔的猫喵喵12 分钟前
天然气压力能利用系统综合性评价平台:基于Python和PyQt5的AHP与模糊综合评价集成应用
开发语言·python·qt
独好紫罗兰24 分钟前
对python的再认识-基于数据结构进行-a004-列表-实用事务
开发语言·数据结构·python
gjxDaniel25 分钟前
Objective-C编程语言入门与常见问题
开发语言·objective-c
choke23336 分钟前
[特殊字符] Python异常处理
开发语言·python
云中飞鸿36 分钟前
linux中qt安装
开发语言·qt
少控科技1 小时前
QT第6个程序 - 网页内容摘取
开发语言·qt
darkb1rd1 小时前
八、PHP SAPI与运行环境差异
开发语言·网络安全·php·webshell