【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();
}
相关推荐
3D打印-HUSTAIBO17 分钟前
QT中connect高级链接——指针、lambda、宏
qt
刘梓谦2 小时前
Qt获取CPU使用率及内存占用大小
开发语言·c++·qt
追烽少年x12 小时前
Qt中在子线程中刷新UI的方法
qt
猫生鱼14 小时前
qml中的TextArea使用QSyntaxHighlighter显示高亮语法
c++·qt
csdn_aspnet15 小时前
WPF 性能 UI 虚拟化 软件开发人员的思考
ui·wpf
課代表18 小时前
Excel VBA 词频统计宏
ui·excel··vba·模块·字典
weixin_4462608521 小时前
提高工作效率的新选择[特殊字符]——Element Plus UI库
ui
feiyangqingyun21 小时前
Qt/C++开发监控GB28181系统/实时视频预览/视频点播/rtp解包解码显示
c++·qt·音视频·gb28181
沐雨潇竹1 天前
使用定时器监视当前PID 如果当前程序关闭 UI_Core.exe 也随之自动关闭实现方法
开发语言·qt·ui
Htht1111 天前
【Qt】之【Bug】点击按钮(ui->pushButton)触发非本类设置的槽函数
qt·ui·bug