当前位置:网站首页>QT 怎么把QWigdet变成QDialog
QT 怎么把QWigdet变成QDialog
2022-04-23 11:15:00 【还债大湿兄】
简单记录,方便自己,老手从从边上无视飞过
首先把QWidget改成QDialog,自己加两个按扭,一般是确认取消,浏览文件之类的,然后添加slot,便可以了,确定和取消时直接调用qt的
#pragma once
#include <QDialog>
#include <QWidget>
#include "ui_QExportResDlg.h"
class QExportResDlg : public QDialog
{
Q_OBJECT
public:
QExportResDlg(QWidget *parent = Q_NULLPTR,bool bExportAll= false);
~QExportResDlg();
QString m_strFilePath;
private:
Ui::QExportResDlg ui;
public slots:
void OnBrowseClick(bool);
void OnConfigSave();
void OnConfigCancle();
private:
bool m_bExportAllFlag;
};
#include "QExportResDlg.h"
#include <QtGui>
#include <QFileDialog>
QExportResDlg::QExportResDlg(QWidget *parent, bool bExportAll )
: QDialog(parent)
{
ui.setupUi(this);
m_bExportAllFlag = bExportAll;
connect(ui.btnConfigOk, SIGNAL(clicked()), this, SLOT(OnConfigSave()));
connect(ui.btnConfigCancle, SIGNAL(clicked()), this, SLOT(OnConfigCancle()));
connect(ui.btnBrow, SIGNAL(clicked(bool)), this, SLOT(OnBrowseClick(bool)));
m_strFilePath = "";
}
QExportResDlg::~QExportResDlg()
{
}
void QExportResDlg::OnBrowseClick(bool)
{
QFileDialog dlg;
dlg.setFileMode(QFileDialog::Directory);
dlg.setOption(QFileDialog::ShowDirsOnly, true);
if (dlg.exec())
{
QString resRoot = dlg.selectedFiles()[0];
ui.btnBrowserDir->setText(resRoot);
m_strFilePath = resRoot;
//ShowUpdateNotice(resRoot);
}
}
void QExportResDlg::OnConfigSave()
{
accept();
}
void QExportResDlg::OnConfigCancle()
{
reject();
}
调用如下:
QExportResDlg dlg(Q_NULLPTR,true);
int code = dlg.exec();
if (code == QDialog::Accepted)
{
}
版权声明
本文为[还债大湿兄]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_30377315/article/details/121855037
边栏推荐
- Learn go language 0x05: the exercise code of map in go language journey
- Understanding of fileprovider path configuration strategy
- Excel·VBA数组冒泡排序函数
- 卷积层和池化层总结
- mysql创建存储过程及函数详解
- 学习 Go 语言 0x06:《Go 语言之旅》中 斐波纳契闭包 练习题代码
- Typora operation skill description (I) md
- 详解MySQL中timestamp和datetime时区问题导致做DTS遇到的坑
- 小程序 支付
- Using El popconfirm and El backtop does not take effect
猜你喜欢
GO接口使用
SVN的使用:
《Neo4j权威指南》简介,求伯君、周鸿袆、胡晓峰、周涛等大咖隆重推荐
Solutions to common problems in visualization (VIII) solutions to problems in shared drawing area
26. 删除有序数组中的重复项
Get things technology network optimization - CDN resource request Optimization Practice
Cygwin 中的 rename 用法
Learn go language 0x04: Code of exercises sliced in go language journey
An interesting interview question
Visual common drawing (I) stacking diagram
随机推荐
使用 PHP PDO ODBC 示例的 Microsoft Access 数据库
MySQL分区表实现按月份归类
《Neo4j权威指南》简介,求伯君、周鸿袆、胡晓峰、周涛等大咖隆重推荐
Visualized common drawing (II) line chart
MBA - day5 mathématiques - Questions d'application - Questions d'ingénierie
年度最尴尬的社死瞬间,是Siri给的
mysql创建存储过程及函数详解
Upgrade the functions available for cpolar intranet penetration
MySQL Router重装后重新连接集群进行引导出现的——此主机中之前已配置过的问题
Typora operation skill description (I)
After the MySQL router is reinstalled, it reconnects to the cluster for boot - a problem that has been configured in this host before
An interesting interview question
Code implementation of general bubbling, selection, insertion, hill and quick sorting
MySQL partition table can be classified by month
Mysql中有关Datetime和Timestamp的使用总结
R-Drop:更强大的Dropout正则方法
Visual common drawing (V) scatter diagram
mysql插入datetime类型字段不加单引号插入不成功
Learning go language 0x02: understanding slice
MySQL8.0升级的踩坑历险记