QT day2

1> 思维导图

2>

使用手动连接,将登录框中的取消按钮使用qt4版本的连接到自定义的槽函数中,在自定义的槽函数中调用关闭函数

将登录按钮使用qt5版本的连接到自定义的槽函数中,在槽函数中判断ui界面上输入的账号是否为"admin",密码是否为"123456",如果账号密码匹配成功,则输出"登录成功",并关闭该界面,如果匹配失败,则输出登录失败,并将密码框中的内容清空

cpp 复制代码
#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->resize(540,430);
    //设置纯净窗口
    this->setStyleSheet("background-color:white");
    this->setWindowFlag(Qt::FramelessWindowHint);

    //设置关闭按钮
    ui->Btn2->setStyleSheet("background-color:yellow;bordor-radius:10px");
    connect(ui->Btn2,SIGNAL(clicked()),this,SLOT(close()));

    //设置标签
    ui->lab5->setPixmap(QPixmap(":/pictrue/logo.png"));
    ui->lab5->setScaledContents(true);
    ui->lab2->setPixmap(QPixmap(":/pictrue/passwd.jpg"));
    ui->lab2->setScaledContents(true);
    ui->lab1->setPixmap(QPixmap(":/pictrue/11.png"));
    ui->lab1->setScaledContents(true);

    //设置行编辑器
    ui->Edit1->setPlaceholderText("账号");
    ui->Edit2->setPlaceholderText("密码");
    ui->Edit2->setEchoMode(QLineEdit::Password);

    //设置按钮
    ui->Btn1->setStyleSheet("background-color:blue");
    connect(ui->Btn1,&QPushButton::clicked,this,&Widget::my_slots);


}

Widget::~Widget()
{
    delete ui;
}

void Widget::my_slots()
{
    if(ui->Edit1->text() == "admin" & ui->Edit2->text() == "123456")
    {
        qDebug() << "登录成功";
        this->close();
    }
    else {
        qDebug() << "登录失败";
        ui->Edit1->clear();
        ui->Edit2->clear();
    }
}
相关推荐
倔强的石头_2 分钟前
Oracle 迁移 TCO 深度拆解:从隐性运维成本陷阱到全栈工具链破局
数据库
sunwenjian8863 分钟前
Spring Boot 整合 Druid 并开启监控
java·spring boot·后端
1104.北光c°8 分钟前
基于Canal + Kafka的高可用关注系统:一主多从关系链
java·开发语言·笔记·分布式·程序人生·kafka·一主多从
2501_924952699 分钟前
Python深度学习入门:TensorFlow 2.0/Keras实战
jvm·数据库·python
Mem0rin10 分钟前
[Java]异常及其处理
java·开发语言
skiy10 分钟前
Spring boot创建时常用的依赖
java·spring boot·后端
2401_8914821711 分钟前
Python多线程与多进程:如何选择?(GIL全局解释器锁详解)
jvm·数据库·python
Predestination王瀞潞12 分钟前
6.3.1 软件->W3C XPath 1.0 标准(W3C Recommendation):XPath(XML Path Language)查询语言
xml·数据库·oracle
2401_8512729912 分钟前
用Python实现自动化的Web测试(Selenium)
jvm·数据库·python
早起的年轻人12 分钟前
告别Git仓库臃肿:一招解决Maven target目录误提交问题
java·git·maven