当前位置:网站首页>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:


边栏推荐
- Pve delete virtual machine "for a collection"
- Transfer learning to freeze the network:
- A new generation of ultra-safe cellular batteries, Sihao Airun goes on sale starting at 139,900 yuan
- Why Metropolis–Hastings Works
- RK3399 platform development series on introduction to (kernel) 1.52, printk function analysis - the function call will be closed
- 表连接详解
- R语言诊断ARIMA模型:forecast包构建了一个ARIMA模型、使用checkresiduals函数诊断ARIMA模型、并进行结果解读(拟合较差的ARIMA模型具有的特点)
- Small application project works WeChat gourmet recipes applet graduation design of finished product (1) the development profile
- Ts-Map 类的使用
- 新书上市 |《谁在掷骰子?》在“不确定性时代”中确定前行
猜你喜欢
随机推荐
小程序毕设作品之微信美食菜谱小程序毕业设计成品(1)开发概要
leetcode/submatrix element sum
Promise learning (1) What is Promise?how to use?How to solve callback hell?
shell--面试题
腾讯云原生:Areaki Mesh 在 2022 冬奥会视频直播应用中的服务网格实践
A new generation of ultra-safe cellular batteries, Sihao Airun goes on sale starting at 139,900 yuan
DBPack SQL Tracing 功能及数据加密功能详解
2022 Go生态圈 rpc 框架 Benchmark
Complete Raiders of JS Data Type Conversion
PDMan-domestic free general database modeling tool (minimalist, beautiful)
R语言诊断ARIMA模型:forecast包构建了一个ARIMA模型、使用checkresiduals函数诊断ARIMA模型、并进行结果解读(拟合较差的ARIMA模型具有的特点)
重庆市大力实施智能建造,推动建筑业数字化转型,助力“建造强市”
(ES6以上以及TS) Map对象转数组
Small application project works WeChat gourmet recipes applet graduation design of finished product (1) the development profile
How to use DevExpress controls to draw flowcharts?After reading this article, you will understand!
July 31, 2022 -- Take your first steps with C# -- Use C# to create readable code with conventions, spaces, and comments
Introduction to STM32 development Introduce IIC bus, read and write AT24C02 (EEPROM) (using analog timing)
R语言两个时间序列数据的滞后相关性可视化:使用forecast包的ccf函数绘制交叉相关函数,根据可视化结果分析滞后相关性
Several methods of appending elements are commonly used in js: append, appendTo, after, before, insertAfter, insertBefore, appendChild
Mini Program Graduation Works WeChat Food Recipes Mini Program Graduation Design Finished Products (2) Mini Program Functions







