【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();
}
相关推荐
speedoooo9 小时前
在现有App里嵌入一个AI协作者
前端·ui·小程序·前端框架·web app
霍格沃兹测试学院-小舟畅学10 小时前
Playwright MCP在UI自动化测试中的定位与思考
ui
Just_Paranoid11 小时前
【Android UI】Android 颜色的表示和获取使用指南
android·ui·theme·color·attr·colorstatelist
恶猫12 小时前
SEELEN UI 桌面自定义工具 v2.3 介绍及安装教程, 深度美化win10/11,装机必备!!
ui·win11·win10·系统优化·桌面·桌面美化·桌面自定义
水煎包V:YEDIYYDS88814 小时前
QT QML 实现的摇杆按钮,类似王者荣耀 左边方向导航键
qt·qml·摇杆按钮·导航键
winfield82115 小时前
MCP 协议详解
开发语言·网络·qt
秦jh_17 小时前
【Qt】常用控件(上)
服务器·数据库·qt
刃神太酷啦17 小时前
C++ list 容器全解析:从构造到模拟实现的深度探索----《Hello C++ Wrold!》(16)--(C/C++)
java·c语言·c++·qt·算法·leetcode·list
水煎包V:YEDIYYDS88817 小时前
QT modbus 通信教程,把modbus封装到线程单例中,在线程内完成数据收发,解析。把重要数据以信号方式通知到qml层展示,解决UI卡顿
qt·modbus·线程服务
东哥很忙XH18 小时前
python使用PyQt5开发桌面端串口通信
开发语言·驱动开发·python·qt