StandardPaths QML Type
提供对标准系统路径的访问权限。更多...
| Import Statement: | import QtCore |
| Since: | Qt 6.2 |
| Inherits: |
方法
- string displayName(StandardLocation type)
- url findExecutable(string executableName, list<string> paths)
- url locate(StandardLocation type, string fileName, LocateOptions options)
- list<url> locateAll(StandardLocation type, string fileName, LocateOptions options)
- list<url> standardLocations(StandardLocation type)
- url writableLocation(StandardLocation type)
详细说明
StandardPaths 单例类型提供了用于查询标准系统路径的方法。
property url documentsFolder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)另请参阅 QStandardPaths 。
方法文档
string displayName(StandardLocation type)
返回给定位置的本地化显示名称type ;如果找不到相关位置,则返回空字符串QString 。
另请参阅 QStandardPaths::displayName()。
url findExecutable(string executableName, list<string> paths)
在指定的paths 中查找名为executableName 的可执行文件;如果paths 为空,则在系统路径中查找。
在大多数操作系统中,系统路径由PATH 环境变量决定。可在paths参数中设置用于搜索可执行文件的目录。 若要在用户路径和系统路径中同时进行搜索,请调用两次 `findExecutable`:一次设置 `paths` 参数,一次不设置 `paths` 参数。为了保持那些行为取决于调用名称的可执行文件的行为一致性,系统不会解析符号链接。
注意:在 Windows系统中 ,会自动附加常见的可执行文件扩展名(来自 PATHEXT 环境变量)。例如,findExecutable("foo") 调用会查找foo.exe 或foo.bat (如果存在的话)。
返回可执行文件的绝对文件路径;若未找到,则返回空字符串。
如果给定的executableName 是指向可执行文件的绝对路径,则返回其“干净”路径。
另请参阅 QStandardPaths::findExecutable()。
url locate(StandardLocation type, string fileName, LocateOptions options)
在type 的标准位置中查找名为fileName 的文件或目录。
options 标志用于指定是搜索文件还是目录。默认情况下,该标志设置为LocateFile 。
返回找到的第一个文件或目录的绝对路径,否则返回空字符串。
另请参阅 QStandardPaths::locate()。
list<url> locateAll(StandardLocation type, string fileName, LocateOptions options)
在type 的标准位置中,查找名称为fileName 的所有文件或目录。
options 标志用于指定要查找的是文件还是目录。默认情况下,该标志设置为LocateFile 。
返回所有找到的文件列表。
另请参阅 QStandardPaths::locateAll()。
list<url> standardLocations(StandardLocation type)
返回所有包含type 类型文件的目录。
目录列表按优先级从高到低排序,如果能确定,则以 `writableLocation()` 为首。如果未为该类型定义任何位置,则该列表为空。
另请参阅 QStandardPaths::standardLocations()。
url writableLocation(StandardLocation type)
返回应将type 文件写入的目录,如果无法确定位置,则返回空字符串。
注意: 返回的存储位置可能不存在;也就是说,可能需要由系统或用户创建该目录 。
另请参阅 QStandardPaths::writableLocation()。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.