【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();
}
相关推荐
xy34532 小时前
Axure9.0 中继器遮罩的核心应用场景(精准适配列表交互)
前端·ui·html·原型·产品设计·axure9.0
skr爱码士7 小时前
15_国际化和本地化:tr()、ts 文件、QM 文件、多语言切换
c++·qt·ui·客户端
Flutter OH8 小时前
Flutter OH 卡死冻屏问题定位指南
flutter·命令模式
Quz8 小时前
QML 拖拽篇:看板拖拽与数字拼图
qt
长友cy9 小时前
Qt官方示例Application源码阅读
开发语言·qt
贝格前端工场10 小时前
AI在生产制造企业的六大成熟落地场景(可量产、可验收、非噱头)
大数据·ui·前端开发
程与留1 天前
15_国际化和本地化:tr()、ts 文件、QM 文件、多语言切换
c++·qt
程与留1 天前
14_Qt 样式表(QSS)入门(语法、选择器、美化实战)
c++·qt
Quz1 天前
QML 拖拽篇:接收拖拽与数据交换
qt
CoderIsArt2 天前
C#中UI 线程与 Dispatcher
开发语言·ui·c#