【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();
}
相关推荐
文创工作室9 小时前
Adobe Illustrator 中文
ui·adobe·illustrator
San813_LDD10 小时前
[QT]《Qt 开发避坑指南:随机数、容器操作与 VS 环境配置》
开发语言·qt
烛衔溟16 小时前
HarmonyOS 基础 UI 构建 —— 组件、布局与沉浸式效果
ui·华为·harmonyos
稷下元歌17 小时前
七天学会plc加机器视觉之AI 接入 外设模块开发全详细操作文档(全程配套视频按文档实操)
python·sql·qt·贪心算法·r语言·wpf·时序数据库
艾莉丝努力练剑17 小时前
【QT】界面优化:QSS
linux·运维·开发语言·网络·qt·计算机网络·udp
雪的季节18 小时前
Qt 自定义表头
开发语言·qt
一次旅行18 小时前
CopilotKit实战:用生成式UI打造智能Agent前端
前端·人工智能·ui
艾莉丝努力练剑19 小时前
【QT】系统相关:QT文件
linux·服务器·开发语言·网络·qt·tcp/ip·计算机网络
爱思考的小伙1 天前
Qt-03:串口助手
qt
gqk011 天前
Delegate.Target/ Method
前端·ui·xhtml