当前位置:网站首页>Qt——选择文件夹并获取路径以及文件夹下子文件
Qt——选择文件夹并获取路径以及文件夹下子文件
2022-08-08 16:54:00 【泉伟】
这个实现比较简单,就是借助Qt中QFileDialog库的getExistingDirectory()函数,可以直接返回当前文件夹的路径。
头文件声明
#include<QFileDialog>
主程序
QString filename = QFileDialog::getExistingDirectory();
获取文件夹下子文件名称
头文件声明
#include <QDebug>
#include<QFileDialog>
主程序
QString filename = QFileDialog::getExistingDirectory();
QDir *dir=new QDir(filename);
QStringList filter;
QList<QFileInfo> *fileInfo=new QList<QFileInfo>(dir->entryInfoList(filter));
for(int i = 0;i<fileInfo->count(); i++)
{
qDebug()<<fileInfo->at(i).filePath();
qDebug()<<fileInfo->at(i).fileName();
}
边栏推荐
猜你喜欢
英特尔两大 FPGA 产品已部署至中国创新中心:性能提高 45%,功耗降低 40%
Digital image processing (6) -- image compression
leetcode:295. 数据流的中位数
【论文阅读】RAL 2022: Receding Moving Object Segmentation in 3D LiDAR Data Using Sparse 4D Convolutions
GHOST tool to access the database
iNFTnews | 元宇宙为企业发展带来新思路
Acwing Week 63 [Unfinished]
【 8.7 】 source code - card to LCM with GCD 】 【 】
leetcode:313. 超级丑数
毕设-基于SSM学生考试系统
随机推荐
R语言4.04安装教程
【20210923】选择感兴趣的研究方向?
leetcode:306. 累加数
JVM-简介&垃圾回收&内存泄漏分析
测试/开发程序员停滞不前,倦怠怎么办?突破各种失败和挫折......
4. S32K14X study notes: S32 Design Studio new and imported projects
NSSCTF部分复现
ESP8266-Arduino编程实例-ADXL345三轴加速计驱动
ImportError: numpy.core.multiarray failed to import [cv2, matplotlib, PyTorch, pyinstaller ]
淘宝API常用接口列表与申请方式
[机缘参悟-64]:《兵者,诡道也》-5-孙子兵法解读-混战计
Chapter 20 Source Code File REST API Reference (2)
[In-depth study of 4G/5G/6G topic-54]: L3 signaling control-3-segmentation of software functions and processes-signaling of CU-UP network elements
看到这个应用上下线方式,不禁感叹:优雅,太优雅了!
leetcode:294.翻转游戏
Obtain - 64 [chances] : the soldier, subtlety also - 5 - read sun tzu - melee meter
bzoj1507 [NOI2003]Editor
元宇宙医疗或将改变医疗格局
它们不一样!透析【观察者模式】和【发布订阅模式】
二、junit接口自动化框架之二次开发