【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();
}
相关推荐
怎么就重名了3 小时前
STM32+蓝牙模块+超声波模块+QT
stm32·嵌入式硬件·qt
864记忆4 小时前
Qt Network 模块中的函数详解
开发语言·网络·qt
864记忆4 小时前
Qt Sql 模块中的函数详解
开发语言·网络·qt
常乐か7 小时前
occ中以鼠标所在位置进行缩放
qt·occ
江公望8 小时前
Qt告警clazy-detaching-temporary浅谈
qt·qml
864记忆8 小时前
Qt QML 模块及其函数详解
开发语言·qt
柒儿吖12 小时前
Qt for HarmonyOS 3D图片轮播组件开源鸿蒙开发实战
qt·3d·harmonyos
rainFFrain13 小时前
qt显示类控件--- Label
开发语言·qt
西游音月13 小时前
(6)框架搭建:Qt实战项目之主窗体快捷工具条
开发语言·qt
Dr.勿忘16 小时前
Unity一分钟思路---UI任务条:宝箱位置如何准确卡在百分比位置上
ui·unity·游戏程序·屏幕适配