当前位置:网站首页>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:
边栏推荐
- MNIST是什么(plist是什么意思)
- 小程序毕设作品之微信美食菜谱小程序毕业设计成品(2)小程序功能
- Solve vscode input! Unable to quickly generate skeletons (three methods for the new version of vscode to quickly generate skeletons)
- 【CLion】CLion 总是提示 “This file does not belong to any project target xxx” 的解决方法
- 新一代超安全蜂窝电池, 思皓爱跑上市13.99万元起售
- 【无标题】
- JS 中的 undefined 和 null 的区别
- Android Security and Protection Policy
- js中常用追加元素的几种方法:append,appendTo,after,before,insertAfter,insertBefore,appendChild
- C#/VB.NET 将PPT或PPTX转换为图像
猜你喜欢
小程序毕设作品之微信美食菜谱小程序毕业设计成品(4)开题报告
音视频技术开发周刊 | 256
程序员如何优雅地解决线上问题?
新书上市 |《谁在掷骰子?》在“不确定性时代”中确定前行
【随心笔记】假期快过去了,都干了点什么
复现assert和eval成功连接或失败连接蚁剑的原因
The four methods of judging JS data type
回归预测 | MATLAB实现TPA-LSTM(时间注意力注意力机制长短期记忆神经网络)多输入单输出
表达式引擎在转转平台的实践
[Open class preview]: Research and application of super-resolution technology in the field of video quality enhancement
随机推荐
利用正则表达式的回溯实现绕过
shell--面试题
Generate certificates using KeyStore
【钛晨报】国家统计局:7月制造业PMI为49%;玖富旗下理财产品涉嫌欺诈,涉及390亿元;国内航线机票燃油附加费8月5日0时起下调
DBPack SQL Tracing 功能及数据加密功能详解
回归预测 | MATLAB实现TPA-LSTM(时间注意力注意力机制长短期记忆神经网络)多输入单输出
[CLion] CLion always prompts "This file does not belong to any project target xxx" solution
OpenHarmony高校技术俱乐部计划发布
Endorsed in 2022 years inventory | product base, science and technology, guangzhou automobile group striding forward
各位大拿,安装Solaris 11.4操作系统,在安装数据库依赖包的时候包这个错,目前无原厂支持,也无安装盘,联网下载后报这个错,请教怎么解决?
LeakCanary如何监听Service、Root View销毁时机?
.NET analyzes the LINQ framework in depth (three: the elegant prelude of LINQ)
Browser shortcut keys
Drawing arrows of WPF screenshot control (5) "Imitation WeChat"
A new generation of ultra-safe cellular batteries, Sihao Airun goes on sale starting at 139,900 yuan
The first experience of Shengsi large model experience platform——Take the small model LeNet as an example
What is a stepper motor?40 pictures to show you!
Istio Meetup China:全栈服务网格 - Aeraki 助你在 Istio 服务网格中管理任何七层流量
Promise学习(四)异步编程的终极解决方案async + await:用同步的方式去写异步代码
R语言两个时间序列数据的滞后相关性可视化:使用forecast包的ccf函数绘制交叉相关函数,根据可视化结果分析滞后相关性