【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();
}
相关推荐
Quz31 分钟前
QML MouseArea:点击、悬停与坐标获取
qt
程与留40 分钟前
04_Qt项目构建流程深度解析——MOC、UIC、RCC 的作用与原理
qt
Quz40 分钟前
QML MouseArea 事件:单击双击、长按与多按键检测
qt
秋田君2 小时前
SqlServer2022 服务以及客户端可视化安装详细教程
qt
山川志~3 小时前
Vue + Element UI 实战:如何实现表格时间、金额字段排序
vue.js·ui·elementui
平常心的技术小牛11 小时前
Qt-快速上手-QMenuBar
开发语言·qt
Oll Correct13 小时前
Adobe illustrator 案例六:手枪图标绘制
笔记·ui·adobe·illustrator
l1m0_21 小时前
React+Tailwind+AI 实战:连锁餐饮管理后台从零到一开发复盘
前端·react.js·ui·ai·ai设计
qq_1508419921 小时前
从CVI(C)到Pyside(python)/Qt(C++)/VS(C#)的一点吐槽
c++·qt·c#
我不是疯子是傻子1 天前
Qt 程序打包部署全攻略:从 windeployqt 到 Inno Setup 的静默安装与版本迭代实战
开发语言·qt