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() 。
在指定的paths 中查找名为executableName 的可执行文件,如果paths 为空,则查找系统路径。
在大多数操作系统中,系统路径由PATH
环境变量决定。搜索可执行文件的目录可在 paths 参数中设置。要同时在自己的路径和系统路径中搜索,可调用两次 findExecutable,一次在路径已设置的情况下,另一次在路径为空的情况下。如果可执行文件的行为取决于其调用的名称,则不会解析系统链接,以保护其行为。
注意: 在 Windows 系统中,通常的可执行文件扩展名(来自 PATHEXT 环境变量)会被自动添加。例如,findExecutable("foo") 调用会查找foo.exe
或foo.bat
(如果存在)。
返回可执行文件的绝对路径,如果未找到,则返回空字符串。
如果给定的executableName 是指向可执行文件的绝对路径,则返回其干净路径。
另请参阅 QStandardPaths::findExecutable().
在type 的标准位置查找名为fileName 的文件或目录。
通过options 标志,可以指定查找文件还是目录。默认情况下,该标志设置为LocateFile
。
返回找到的第一个文件或目录的绝对路径,否则返回空字符串。
另请参阅 QStandardPaths::locate() 。
在type 的标准位置查找名称为fileName 的所有文件或目录。
通过options 标志,可以指定是否查找文件或目录。默认情况下,该标记设置为LocateFile
。
返回找到的所有文件的列表。
另请参阅 QStandardPaths::locateAll() 。
返回type 文件所属的所有目录。
目录列表按优先级从高到低排序,如果可以确定,则从writableLocation() 开始。如果没有定义类型的位置,则该列表为空。
url writableLocation(StandardLocation type) |
返回type 文件应写入的目录,如果无法确定位置,则返回空字符串。
注意: 返回的存储位置可能不存在;也就是说,它可能需要由系统或用户创建。
另请参阅 QStandardPaths::writableLocation().
© 2025 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.