【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();
}
相关推荐
mengzhi啊2 小时前
QPluginLoader 动态 DLL 插件版,支持插件之间通信,广播。请求和应答
c++·qt
老赵的博客5 小时前
c++ QT之动态库加载问题
c++·qt
Quz10 小时前
QML Loader:动态创建控件与延迟加载
qt
Quz10 小时前
QML Loader:组件切换与属性传递
qt
老赵的博客10 小时前
c++QT之动态库加载常见报错
c++·qt
码匠许师傅11 小时前
【设计模式精讲】25.状态模式(State)
c++·ui·设计模式·状态模式·uml
插件开发1 天前
Illustrator 插件开发:链接文件存在检查的原理与实战
ui·illustrator
xy34531 天前
axure9.0 如何打造一个计时器(简单版)
前端·ui·html·axure·原型·产品设计
Quz1 天前
QML Loader:从文件加载组件、加载内联组件
qt
Quz1 天前
QML Loader: 状态监听与动态标签页
qt