2024.3.22 QT

思维导图

使用手动连接,将登录框中的取消按钮使用qt4版本的连接到自定义的槽函数中,在自定义的槽函数中调用关闭函数将登录按钮使用qt5版本的连接到自定义的槽函数中,在槽函数中判断ui界面上输入的账号是否为"admin",密码是否为"123456",如果账号密码匹配成功,则输出“登录成功”,并关闭该界面,如果匹配失败,则输出登录失败,并将密码框中的内容清空自己完成一个使用qss的登陆窗口界面。

头文件:

#ifndef WIDGET_H
#define WIDGET_H
 
#include <QWidget>
#include <QString>
#include <QDebug>
 
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE
 
class Widget : public QWidget
{
    Q_OBJECT
 
public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
 
private slots:
    void on_btn2_clicked();
    void my_slot();
    void bt1_slot();
 
private:
    Ui::Widget *ui;
};
#endif // WIDGET_H

 源文件:

#include "widget.h"
#include "ui_widget.h"
 
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //去掉头部
    this->setWindowFlag(Qt::FramelessWindowHint);
    //去掉空白的地方
    this->setAttribute(Qt::WA_TranslucentBackground);
    //连接按钮2的信号和槽函数 基于qt4版本
    connect(ui->btn2,SIGNAL(clicked()),this,SLOT(my_slot()));
    //连接信号和自定义槽函数,基于qt5版本的连接
    connect(ui->btn1,&QPushButton::clicked,this,&Widget::bt1_slot);
 
 
}
 
Widget::~Widget()
{
    delete ui;
}
 
 
 
 
void Widget::on_btn2_clicked()
{
 
}
 
void Widget::my_slot()
{
    this->close();
 
}
 
void Widget::bt1_slot()
{
    QString str1 = "admin";
    QString str2 = ui->usenameEdit->text();
    QString passwd = "123456";
    QString passwd2 = ui->passwdEdit->text();
    if(str1 == str2 && passwd == passwd2)
    {
       qDebug() << "登录成功!";
       this->close();
    }
    else
    {
        qDebug() << "登录失败";
 
        ui->passwdEdit->clear();
 
    }
 
 
}

相关推荐

  1. 20240322 大模型快讯

    2024-03-28 18:08:02       43 阅读
  2. <span style='color:red;'>QT</span>

    QT

    2024-03-28 18:08:02      30 阅读
  3. <span style='color:red;'>QT</span>

    QT

    2024-03-28 18:08:02      40 阅读
  4. Qt 使用qm文件

    2024-03-28 18:08:02       33 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-28 18:08:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-28 18:08:02       101 阅读
  3. 在Django里面运行非项目文件

    2024-03-28 18:08:02       82 阅读
  4. Python语言-面向对象

    2024-03-28 18:08:02       91 阅读

热门阅读

  1. 观察者模式和发布-订阅模式有什么异同

    2024-03-28 18:08:02       38 阅读
  2. C语言中实现atoi函数实现

    2024-03-28 18:08:02       36 阅读
  3. 力扣由浅至深 每日一题.16 合并两个有序数组

    2024-03-28 18:08:02       48 阅读
  4. 深度学习系列63:tts和智能语音助手

    2024-03-28 18:08:02       46 阅读
  5. vue组件间通信详解

    2024-03-28 18:08:02       46 阅读
  6. 语言模型transformers调用部分 (To be continue...

    2024-03-28 18:08:02       43 阅读
  7. C语言:指针进阶

    2024-03-28 18:08:02       52 阅读
  8. Python入门级题目及答案

    2024-03-28 18:08:02       39 阅读
  9. 利用python脚本,根据词条爬取百度图片(爬虫)

    2024-03-28 18:08:02       39 阅读
  10. linux内核网络“每日读书”

    2024-03-28 18:08:02       43 阅读