【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();
}
相关推荐
Y1rong2 小时前
C++ QT之记事本
开发语言·qt
IOT-Power6 小时前
QT 串口 源码结构框架
qt
灵感菇_8 小时前
Flutter Riverpod 完整教程:从入门到实战
前端·flutter·ui·状态管理
2022.11.7始学前端10 小时前
n8n第七节 只提醒重要的待办
前端·javascript·ui·n8n
世转神风-10 小时前
winDbg专有名词解释
qt·windbg
尤老师FPGA11 小时前
使用ZYNQ芯片和LVGL框架实现用户高刷新UI设计系列教程(第四十讲)
ui
成富12 小时前
Chat Agent UI,类似 ChatGPT 的聊天界面,Spring AI 应用的测试工具
java·人工智能·spring·ui·chatgpt
2401_8534482314 小时前
项目图片功能制作
linux·数据库·qt·系统移植
小a彤14 小时前
Flutter UI 美化与适配技巧详解
flutter·ui
深蓝海拓14 小时前
QT中具有重载特性的一些部件
python·qt·pyqt