【QT-UI】

1.使用手动连接,将登录框中的取消按钮使用qt4版本的连接到自定义的槽函数中,在自定义的槽函数中调用关闭函数
cpp 复制代码
#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
//使用qt4将右上角x设置关闭触发
    connect(btn2,SIGNAL(clicked()),this,SLOT(close_slot()));

    //使用qt5将快速登录按钮设置触发事件
    connect(btn1,&QPushButton::clicked,this,&MyWidget::log_slot);
}

void MyWidget::close_slot()
{
    this->close();
}

void MyWidget::log_slot(){
    //比较账号和密码
    if(QString::compare("admin",edt1->text())==0 && QString::compare("123456",edt2->text())==0){
        qDebug()<<"登录成功";
        this->close();
    }else {
        edt2->clear();
        qDebug()<<"登录失败";
    }
}

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

void MainWindow::on_closebtn_clicked()
{
    this->close();
}
相关推荐
richard_yuu1 小时前
JSON vs XML vs 二进制:3种序列化终极选型
xml·c++·qt·学习·json
秋田君1 小时前
QT_实战TCP 聊天程序说明文档以及实现
数据库·qt·tcp/ip
阿部多瑞 ABU2 小时前
告别手工核图:基于 .NET + MuPDFCore 的 CAD 等轴测 PDF 材料表提取与新旧版本对比实战
后端·算法·ui·pdf·c#
byxdaz15 小时前
QT中服务使用
开发语言·qt
MoSTChillax21 小时前
UI规范设计:从视觉到交互的全面指南
前端·ui·产品经理·设计规范·vibecoding
秋田君1 天前
QT_网络编程体系
网络·arm开发·qt
Quz1 天前
QML TextArea 实战(下):大文本加载与性能优化
qt
Quz1 天前
QML TextArea 实战(中):Markdown 渲染与保持滚动
qt
Devlab1 天前
LVGL设计大师——网页版anyui来了!!
嵌入式硬件·物联网·低代码·ui·iot
C++ 老炮儿的技术栈2 天前
基于Qt实现轻量化本地音乐播放器
开发语言·c++·qt·c·播放器·音乐