当前位置:网站首页>Qt get all files in a folder
Qt get all files in a folder
2022-08-01 11:31:00 【Nine pounds fifteenpence_】
Record a common function here, get the files under the folder, or the operation of the folder.And output the directory on the combox control:
The functions of the following two functions are to get the subfolder under the specified folder and get the specified file under the specified folder.Note that files of the specified type can be obtained through setNameFilters.
//Dirs listint QtGuiApplication::getDirs(const QString& dirName){QDir* dirinfo = new QDir(dirName);if (!dirinfo->exists()) {delete dirinfo, dirinfo = nullptr;return -1;}QStringList dirList = dirinfo->entryList(QDir::Dirs);dirList.removeOne(".");dirList.removeOne("..");ui.comboBox->clear();ui.comboBox->addItems(dirList);delete dirinfo, dirinfo = nullptr;return 0;}//Files listint QtGuiApplication::getFiles(const QString& dirName){QDir* dirinfo = new QDir(dirName);if (!dirinfo->exists()) {delete dirinfo, dirinfo = nullptr;return -1;}dirinfo->setNameFilters(QStringList("*.png"));QStringList fileList = dirinfo->entryList(QDir::Files);fileList.removeOne(".");fileList.removeOne("..");ui.comboBox_2->clear();ui.comboBox_2->addItems(fileList);delete dirinfo, dirinfo = nullptr;return 0;}The results are as follows:


边栏推荐
- (ES6 and above and TS) Map object to array
- 在线GC日志分析工具——GCeasy
- .NET深入解析LINQ框架(三:LINQ优雅的前奏)
- [Nodejs] node的fs模块
- (ES6以上以及TS) Map对象转数组
- 小程序毕设作品之微信美食菜谱小程序毕业设计成品(4)开题报告
- R语言拟合ARIMA模型:使用forecast包中的auto.arima函数自动搜索最佳参数组合、模型阶数(p,d,q)、设置seasonal参数指定在模型中是否包含季节信息
- pgAdmin 4 v6.12 发布,PostgreSQL 开源图形化管理工具
- 如何成功通过 CKA 考试?
- 利用正则表达式的回溯实现绕过
猜你喜欢

一篇文章,带你详细了解华为认证体系证书(1)

OpenHarmony高校技术俱乐部计划发布

【likeshop】回收租凭系统100%开源无加密 商城+回收+租赁

程序员如何优雅地解决线上问题?

EasyRecovery热门免费数据检测修复软件

Excel表格打印时不打印标记填充颜色

Sparse representation - study notes

How to use DevExpress controls to draw flowcharts?After reading this article, you will understand!

解决vscode输入! 无法快捷生成骨架(新版vscode快速生成骨架的三种方法)

收藏|机械工程师面试常问问题
随机推荐
深入理解 Istio —— 云原生服务网格进阶实战
js中常用追加元素的几种方法:append,appendTo,after,before,insertAfter,insertBefore,appendChild
2022 Go生态圈 rpc 框架 Benchmark
上周热点回顾(7.25-7.31)
sql中ddl和dml(数据库表与视图的区别)
每日一题:连续子数组的最大和(动态规划)
Promise learning (4) The ultimate solution for asynchronous programming async + await: write asynchronous code in a synchronous way
音视频技术开发周刊 | 256
MFC实现交通图导航系统
[Cloud Residency Co-Creation] Huawei Cloud Global Scheduling Technology and Practice of Distributed Technology
回归预测 | MATLAB实现RNN循环神经网络多输入单输出数据预测
R语言ggplot2可视化:使用ggpubr包的ggdensity函数可视化密度图、使用stat_central_tendency函数在密度中添加均值竖线并自定义线条类型
万字解析:vector类
千万级乘客排队系统重构&压测方案——总结篇
Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (4) Opening Report
Excel表格打印时不打印标记填充颜色
Introduction to data warehouse layering (real-time data warehouse architecture)
[Nodejs] node的fs模块
Dapr 与 NestJs ,实战编写一个 Pub & Sub 装饰器
C语言实现!20000用4秒计算