【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();
}
相关推荐
Mr..Jackey9 小时前
瑞佑 RUI Builder 图形化 UI 设计工具
arm开发·人工智能·单片机·ui·人机交互·ra8889·lcd控制芯片
狼哥168610 小时前
《新闻资讯》二、公共能力层模块实现指南
ui·华为·harmonyos
挂科边缘12 小时前
MonkeyQt组件库,基于 PySide6 搭建的 UI 组件库,68种主题样式
ui·pyside6·monkeyqt
郝学胜_神的一滴15 小时前
Qt 高级开发 031:QListWidget图标布局实战
c++·qt
namexingyun15 小时前
开源前端生态如何成为 AI UI 生成的“燃料“:shadcn/ui、Tailwind CSS、Storybook 技术价值全解剖
java·前端·人工智能·python·ui·开源·ai编程
Vertira16 小时前
如何对QT开发的软件进行打包[已解决]
开发语言·qt
LT101579744416 小时前
2026年UI自动化测试平台选型指南:全界面自动化覆盖方案
运维·ui·自动化
大智兄16 小时前
128.配置qt(交叉)编译的路径---解决无法编译的问题
qt
Java知识技术分享17 小时前
opencode安装ui-ux-pro-max和frontend-ui-ux技能
人工智能·ui·个人开发·ai编程·ux
里昆19 小时前
【illustrator】如何在illustrator中画箭头
ui·illustrator