可以使用
qt.conf
文件以覆盖路径或指定要传递给平台插件的自变量。
The
qt.conf
文件是 INI 文本文件,作为描述在
QSettings
文档编制。
QLibraryInfo
将加载
qt.conf
从以下位置之一:
:/qt/etc/qt.conf
使用资源系统
assistant.app/Contents/Resources/qt.conf
The
qt.conf
file can be used to override the hard-coded paths that are compiled into the Qt library. These paths are accessible using the
QLibraryInfo
class. Without
qt.conf
, the functions in
QLibraryInfo
return these hard-coded paths; otherwise they return the paths as specified in
qt.conf
.
Without
qt.conf
, the Qt libraries will use the hard-coded paths to look for plugins, translations, and so on. These paths may not exist on the target system, or they may not be accessible. Because of this, you may need
qt.conf
to make the Qt libraries look elsewhere.
The file should have a
Paths
group which contains the entries that correspond to each value of the QLibraryInfo::LibraryLocation enum. See the
QLibraryInfo
documentation for details on the meaning of the various locations.
Entry | 默认值 |
---|---|
前缀 | QCoreApplication::applicationDirPath () |
文档编制 |
doc
|
头 |
包括
|
库 |
lib
|
LibraryExecutables |
libexec
on Unix,
bin
在 Windows
|
Binaries |
bin
|
插件 |
plugins
|
QmlImports |
qml
|
ArchData |
.
|
数据 |
.
|
翻译 |
translations
|
范例 |
examples
|
测试 |
tests
|
设置 |
.
|
Absolute paths are used as specified in the
qt.conf
file. All paths are relative to the
前缀
. On Windows and X11, the
前缀
is relative to the directory containing the application executable (
QCoreApplication::applicationDirPath
()). On macOS, the
前缀
is relative to the
内容
in the application bundle. For example,
application.app/Contents/plugins/
is the default location for loading Qt plugins. Note that the plugins need to be placed in specific sub-directories under the
plugins
directory (see
如何创建 Qt 插件
了解细节)。
注意:
For backwards-compatibility, the entry
Qml2Imports
is valid in the
Paths
section and is treated as fallback for
QmlImports
.
For example, a
qt.conf
file could contain the following:
[Paths] Prefix = /some/path Translations = i18n
注意: The backslash character is treated as a special character in INI files (see QSettings ). It is therefore recommended to use forward slashes for paths on Windows as well. Otherwise, an escape character is required:
Prefix = c:\\SomePath
The
qt.conf
可能包含
平台
group, whose keys are comma-delimited lists of arguments to be passed to the platform plugin. The key name is the name of the platform plugin with the first letter upper-cased followed by
自变量
.
例如:
[Platforms] WindowsArguments = fontengine=freetype
would cause the Windows platform plugin to use the FreeType font engine.
For environments that require an installation of an earlier major version of Qt as well, it is possible to use a version-specific qt.conf. This is often necessary in transition phases from one Qt version to the next, or to avoid conflicts caused by an existing file without version.
For this purpose, a file named
qt6.conf
can be used instead of the
qt.conf
file. If both files exist in the directory described above,
qt6.conf
被使用。