StandardPaths QML Type
標準のシステムパスへのアクセスを提供します。詳細...
| Import Statement: | import Qt.labs.platform |
| Inherits: | |
| Status: | Deprecated since 6.4 |
この型は Qt Labs Platform 6.4 以降、非推奨となっています。新しいコードでの使用は強く推奨しません。
メソッド
- 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)
- void setTestModeEnabled(bool testMode)
- list<url> standardLocations(StandardLocation type)
- url writableLocation(StandardLocation type)
詳細な説明
代わりに QtCore::StandardPaths を使用してください。
StandardPaths シングルトン型は、標準のシステムパスを照会するためのメソッドを提供します。標準パスは、主にFileDialog およびFolderDialog 型と組み合わせて使用すると便利です。
FileDialog {
folder: StandardPaths.writableLocation(StandardPaths.DocumentsLocation)
}注: Qt.labs モジュール内の型は、将来のバージョンでも互換性が維持されるとは限りません。
QtCore::StandardPaths 、FileDialog 、FolderDialog 、およびQStandardPathsも参照してください 。
メソッドのドキュメント
string displayName(StandardLocation type)
指定されたロケーション `type ` のローカライズされた表示名を返します。関連するロケーションが見つからない場合は、空の `QString ` を返します。
QStandardPaths::displayName()も参照してください 。
url findExecutable(string executableName, list<string> paths)
指定されたpaths 内のexecutableName という名前の実行ファイル、またはpaths が空の場合にはシステムパス内を検索します。
ほとんどのオペレーティングシステムでは、システムパスは `PATH ` 環境変数によって決定されます。実行ファイルを検索するディレクトリは、`paths` 引数で設定できます。 独自のパスとシステムパスの両方を検索するには、`findExecutable` を 2 回呼び出します。1 回目は `paths` を設定して、2 回目は `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()も参照してください 。
void setTestModeEnabled(bool testMode)
testMode の値がtrue の場合、QStandardPaths で特別な「テストモード」が有効になり、書き込み可能な場所がテスト用ディレクトリを指すように変更されます。これにより、自動テストが現在のユーザーの設定を読み込んだり書き込んだりすることを防ぎます。
この設定は、テストプログラムがファイルを書き込む可能性のある以下の場所に影響します:GenericDataLocation 、AppDataLocation 、ConfigLocation 、GenericConfigLocation 、AppConfigLocation 、StateLocation 、GenericStateLocation 、GenericCacheLocation 、およびCacheLocation 。その他の場所は影響を受けません。
Unix では、XDG_DATA_HOME は~/.qttest/share に、XDG_CONFIG_HOME は~/.qttest/config に、XDG_STATE_HOME は~/.qttest/state に、XDG_CACHE_HOME は~/.qttest/cache に設定されています。
macOSでは、データは~/.qttest/Application Support に、キャッシュは~/.qttest/Cache に、設定ファイルは~/.qttest/Preferences に保存されます。
Windowsでは、すべてのデータが%APPDATA% の下にある「qttest」ディレクトリに保存されます。
QStandardPaths::setTestModeEnabled()も参照してください 。
list<url> standardLocations(StandardLocation type)
type のファイルが存在するすべてのディレクトリを返します。
ディレクトリのリストは、優先度の高い順にソートされ、writableLocation() が特定できる場合はそこから始まります。type に対応する場所が定義されていない場合、このリストは空になります。
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.