【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();
}
相关推荐
ZC跨境爬虫1 小时前
跟着 MDN 学 HTML day_2:(表单分组与高级输入控件实战)
前端·javascript·css·ui·html
Lhan.zzZ1 小时前
笔记_2026.4.28_003
c++·笔记·qt·opencv
吴声子夜歌1 小时前
Vue3——UI组件库Element Plus(一)
vue.js·ui·elementplus
m0_635647481 小时前
Qt打包含有第三方库的软件为应用程序——CQtDeployer
开发语言·数据库·qt
for_ever_love__3 小时前
UI学习:单例传值
学习·ui·ios·objective-c
for_ever_love__3 小时前
UI学习:通知传值
学习·ui·ios·objective-c
ximu_polaris3 小时前
设计模式(C++)-行为型模式-命令模式
c++·设计模式·命令模式
ZC跨境爬虫3 小时前
跟着 MDN 学 HTML day_1:(全套原生Input+表单结构拆解)
前端·css·ui·html
慕容卡卡3 小时前
Claude 使用神器(web页面)--CloudCLI UI
java·开发语言·前端·人工智能·ui·spring cloud
qq_452396234 小时前
第十四篇:《持续集成中的UI自动化:Jenkins/GitHub Actions集成》
ui·ci/cd·自动化