当前位置:网站首页>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
边栏推荐
猜你喜欢

Jupyter Lab 十大高生产力插件

使用 PHP PDO ODBC 示例的 Microsoft Access 数据库

Visual common drawing (V) scatter diagram

Microsoft Access database using PHP PDO ODBC sample

分享两个实用的shell脚本

Constraintlayout layout

Upgrade the functions available for cpolar intranet penetration

数据库管理软件SQLPro for SQLite for Mac 2022.30

精彩回顾|「源」来如此 第六期 - 开源经济与产业投资

VIM + ctags + cscope development environment construction guide
随机推荐
remote: Support for password authentication was removed on August 13, 2021.
When the activity is in progress! Click the link to join the live studio to participate in "can AI really save energy?" Let's have a discussion!
小程序 支付
Cygwin 中的 rename 用法
Learning go language 0x01: start from the official website
Usage of rename in cygwin
Learn go language 0x07: stringer exercise code in go language journey
防止web项目中的SQL注入
妊娠箱和分娩箱的区别
Jupyter lab top ten high productivity plug-ins
第六站神京门户-------手机号码的转换
面向全球市场,PlatoFarm今日登录HUOBI等全球四大平台
Mysql系列SQL查询语句书写顺序及执行顺序详解
Constraintlayout layout
@valid,@Validated 的学习笔记
得物技术网络优化-CDN资源请求优化实践
升级cpolar内网穿透能获得的功能
Implementation of inserting millions of data into MySQL database in 10 seconds
How to use JDBC callablestatement The wasnull () method is called to check whether the value of the last out parameter is SQL null
Google Earth Engine(GEE)——将原始影像进行升尺度计算(以海南市为例)