【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();
}
相关推荐
数据法师1 分钟前
Crow Translate :开源桌面划词翻译工具
c++·qt·开源
尤老师FPGA1 小时前
QT代码自适应窗口
开发语言·qt
ZC跨境爬虫1 小时前
跟着 MDN 学CSS day_44:响应式设计——让网页适配所有屏幕的完整指南
前端·css·ui·html·tensorflow
ZC跨境爬虫4 小时前
跟着 MDN 学CSS day_43:CSS布局挑战——从浮动到弹性盒与栅格的综合实践
前端·css·ui·html·tensorflow
郝学胜-神的一滴4 小时前
Qt 高级开发 022:栅格布局深度实战
开发语言·c++·qt·软件构建·用户界面
sycmancia5 小时前
Qt——程序中的配置文件
开发语言·qt
夜空孤狼啸5 小时前
Vue Data UI:这不是图表库,是数据可视化 UI 平台
vue.js·ui·信息可视化
郝学胜_神的一滴20 小时前
Qt 高级开发 021:零基础吃透 QVBoxLayout 垂直布局
c++·qt
ZC跨境爬虫1 天前
跟着 MDN 学CSS day_37:(从文档流到粘性定位的底层原理)
前端·javascript·css·ui·html
G_dou_1 天前
Flutter三方库适配OpenHarmony【compass】罗盘 UI 项目完整实战
flutter·ui