当前位置:网站首页>Qt——获取文件夹下所有子文件名称
Qt——获取文件夹下所有子文件名称
2022-08-08 16:54:00 【泉伟】
在头文件夹声明
#include <QDebug>
#include<QFileDialog>
主程序
QString filePath;
QDir *dir=new QDir(filePath);
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();
}
在上述程序中将文件夹的路径赋值给filePath
,主要路径格式,需要使用“\‘’或者“/”。
例如
C:/Users/1102/Desktop
或者
C:\\Users\\1102\\Desktop
显示结果
"C:/Users/1102/Desktop/."
"C:/Users/1102/Desktop/.."
生成文件结果中会包含后缀为“.‘’与“…”,这两个分别表示为当前目录与上一级目录。
边栏推荐
- ctfshow七夕杯复现
- L2-026 小字辈 (25 分)
- 数字图像处理(六)—— 图像压缩
- 调研阶段复盘
- R语言(数值、列表、矩阵)上应用函数(sqrt、round、mean、log)、将矩阵所有数据求对数、就矩阵整体的均值、使用apply函数计算矩阵matrix的行均值、列均值、trim设置返回结果精度
- 差分约束做法
- 英特尔两大 FPGA 产品已部署至中国创新中心:性能提高 45%,功耗降低 40%
- 第二十章 源代码文件 REST API 参考(二)
- 高数_证明_基本初等函数的导数公式
- Solve the inexplicable problem of MySQL violently - restart the service!
猜你喜欢
函数节流与函数防抖
测试/开发程序员停滞不前,倦怠怎么办?突破各种失败和挫折......
五、jmeter脚本的基本构成&断言
英特尔两大 FPGA 产品已部署至中国创新中心:性能提高 45%,功耗降低 40%
智能指针学习笔记
MySQL database
The latest research from PNAS: 81% problem solving rate, neural network Codex opens the door to the world of advanced mathematics
【数学模型】TOPSIS
二、pytest+selenium+allure实现web ui自动化
【入门PCB】立创eda的学习
随机推荐
Acwing Week 63 [Unfinished]
英特尔两大 FPGA 产品已部署至中国创新中心:性能提高 45%,功耗降低 40%
redis介绍&命令&性能相关&缓存穿透
MySQL database
APICloud AVM wraps date and time selection components
LeetCode_回溯_中等_491.递增子序列
L2-017 人以群分 (25 分)
laravel database: query builder
Spam accounts are a lot of trouble, and device fingerprints are quickly found
数字图像处理(六)—— 图像压缩
测试/开发程序员停滞不前,倦怠怎么办?突破各种失败和挫折......
字节一面:TCP 和 UDP 可以使用同一个端口吗?
差分约束做法
毕设-基于SSM学生考试系统
二、pytest+selenium+allure实现web ui自动化
B. Stairs
ERROR Failed to compile with 1 error
laravel数据库: 查询构造器
它们不一样!透析【观察者模式】和【发布订阅模式】
[深入研究4G/5G/6G专题-54]: L3信令控制-3-软件功能与流程的切分-CU-UP网元的信令