美文网首页
Qt 打印目录和目录下的文件名

Qt 打印目录和目录下的文件名

作者: Caiaolun | 来源:发表于2020-02-21 16:31 被阅读0次
    QString stPath = "../../data";
    QDir dir(stPath);
    QStringList nameFilters;
    nameFilters<< "*.jpg" << "*.png";

    //QDir::Dirs: find directory
    //QDir::Readable find is read files
    //QDir::NoDotAndDotDot not find . and ..
    //QDir::Name Name sort
    QStringList stBranchPath = dir.entryList(QDir::Dirs|QDir::Readable|QDir::NoDotAndDotDot, QDir::Name);
    if(stBranchPath.isEmpty())
        qDebug("directorys are mpty");
    else
    {
        for(int i = 0; i < stBranchPath.size(); i++)
        {
            QString tem = stBranchPath.at(i);
            qDebug()<<"stBranchPath: "<<dir.filePath(tem);

            QDir stDir(dir.filePath(tem));
            //nameFilters just find *.jpg and *.png
            //QDir::Files: find Files
            //QDir::Readable find is read files
            //QDir::NoDotAndDotDot not find . and ..
            //QDir::Name Name sort
            QStringList stFileList = stDir.entryList(nameFilters, QDir::Files|QDir::Readable|QDir::NoDotAndDotDot, QDir::Name);
            if(stFileList.isEmpty())
                qDebug("files are mpty");
            else
            {
                for(int i = 0; i < stFileList.size(); i++)
                {
                    QString tem = stFileList.at(i);
                    qDebug()<<"BranchPath fileName: "<<tem;
                }
            }

        }
    }

相关文章

  • Qt 打印目录和目录下的文件名

  • 部分Linux命令介绍

    命令:ls 用于查看指定目录下的内容 语法 ls -a //显示当前目录下所有文件和目录(将以“.”文件名或目...

  • linux 常用命令

    pwd 显示当前目录ls显示文件或目录 文件名-l:列出文件详细信息l(list)-a:列出当前目录下所有文件及目...

  • 小工具

    是用来获取目录下的文件名的工具 是用来重命名的工具 获取后缀名为.apk的文件名.txt 获取目录和子目录的文件名

  • Python3实现特定文件寻找

    功能 在给定目录以及目录的所有子目录下查找文件名包含指定字符串的文件,并打印出绝对路径。 程序 程序运行截图 主要...

  • Linux 基础2

    2018/10/9 Linux 基本命令: cat+文件名 打印当前目录下的某文件内容(不需要gui系统)cat...

  • Python3 搜索文件名称

    Python3 学习 编写一个程序,能在当前目录以及当前目录的所有子目录下查找文件名包含指定字符串的文件,并打印出...

  • shell 目录下检索字符串

    查找目录下的所有文件中是否含有某个字符串,并且只打印出文件名find . -name "*.type" | xar...

  • Qt 打包Exe文件

    使用类似D:\Qt\Qt5.14.2\5.14.2\mingw73_64\bin目录下的windeployqt.e...

  • 2018-11-20

    ls:查看文件名和目录,用法:$ ls [选项] $ ls 直接输入ls命令,则列出当前目录下的所有文件和目录,不...

网友评论

      本文标题:Qt 打印目录和目录下的文件名

      本文链接:https://www.haomeiwen.com/subject/oqocqhtx.html