【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();
}
相关推荐
bug和崩溃我都要1 小时前
QT 开发的专业截图录屏工具 - macOS版 / Windows版
windows·qt·mac·录屏·截屏
刘科领2 小时前
使用ollama & openweb-ui 本地搭建自己的AI
人工智能·python·ui·ai
加载力科技3 小时前
Mac 打开 ISO 文件完整教程:3 种方法挂载与解压,挂载失败也能提取文件
macos·命令模式·磁盘工具·mac打开iso·hdiutil·iso解压·mac技巧
Python图像识别4 小时前
40-【2027毕设】YOLO11面部口罩检测识别系统 - Python完整源码+PyQt5界面+训练模型+数据集
python·qt·课程设计
Python图像识别4 小时前
39-【2027毕设】YOLO11行人摔倒检测系统 - Python完整源码+PyQt5界面+训练模型+数据集
python·qt·课程设计
xy345311 小时前
Axure 9.0 动态面板基本操作
前端·ui·html·axure·原型·产品设计
Quz14 小时前
QML PathView:直线路径与曲线路径
qt·动画·qml
霍格沃兹测试学院-小舟畅学15 小时前
UI 智能遍历测试:状态识别、路径规划与覆盖率评估
microsoft·ui
Pocker_Spades_A16 小时前
Penpot自托管设计协作:Docker部署、MCP接入与Codex生成UI实操记录
ui·docker·容器
扶尔魔ocy16 小时前
【qt openGL入门笔记】OSG实现飞机模型在网格图上飞行
qt·opengl·osg