QT编程中用于查找特定类型文件(例如:*.cpp)的函数是什么?

发布于 2024-12-24 01:58:57 字数 47 浏览 2 评论 0原文

我需要在电脑上查找特定类型的文件。谁能给我一个可以用来查找系统文件的函数的名称?

I need to find particular type of file on the PC. Can anyone give me the name of a function which I can use to find the system files ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心碎无痕… 2024-12-31 01:58:57

您可能需要 QDir 类 和/或 QFileInfo 类。您想要对这些对象使用什么方法取决于您想要做什么以及如何做。

You probably want either the QDir class and/or the QFileInfo class. What method(s) you want to use on those objects depends on exactly what it is you want to do and how you want to do it.

又爬满兰若 2024-12-31 01:58:57

您可以尝试在 QDir 中使用 setSearchPaths 方法。取决于您要寻找什么。

“Qt 使用此搜索路径来查找具有已知前缀的文件。”

You could try using the setSearchPaths method in QDir. Depends on what you're looking for.

"Qt uses this search path to locate files with a known prefix."

合久必婚 2024-12-31 01:58:57

Qt 提供了一个 QDirIterator ,其带有 QDir::文件| QDir::NoSymLinksQDirIterator::Subdirectories 标志可用于迭代每个项目,如有必要,可获取 .fileInfo().completeSuffix().fileInfo().suffix() (根据需要)检查扩展名类型(“cpp” - 无点),并对文件执行您想要的操作。

Qt provides a QDirIterator which with the QDir::Files | QDir::NoSymLinks and theQDirIterator::Subdirectories flags you can use to iterate over each item, if necessary getting .fileInfo().completeSuffix() or .fileInfo().suffix() (as desired) to check the extension type ("cpp" - no dot), and do with the file what you will.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文