qt QLibraryInfo

QLibraryInfo::PrefixPath

0 所有路径的默认前缀

QLibraryInfo::DocumentationPath

1 安装路径中文档位置

QLibraryInfo::HeadersPath

2 头文件位置

QLibraryInfo::LibrariesPath

3 库的安装位置

QLibraryInfo::LibraryExecutablesPath

4 库在运行时所需的已安装可执行文件的位置

QLibraryInfo::BinariesPath

5 Qt二进制文件(工具和应用程序)安装位置

QLibraryInfo::PluginsPath

6 Qt插件位置

QLibraryInfo::ImportsPath

7 QML扩展用于导入的安装位置(QML 1.x)。

QLibraryInfo::Qml2ImportsPath

8 QML扩展用于导入的安装位置(QML 2.x)。

QLibraryInfo::ArchDataPath

9 通用的、和操作系统有关的Qt数据位置

QLibraryInfo::DataPath

10 通用的、和操作系统无关的Qt数据位置

QLibraryInfo::TranslationsPath

11 Qt字符串翻译信息的位置

QLibraryInfo::ExamplesPath

12 位于安装目录下,Qt例子位置。

QLibraryInfo::TestsPath

13 Qt安装目录下测试用例位置

QLibraryInfo::SettingsPath

100 Qt设置位置,在Windows下不起作用,无意义。

qt.conf

2.1.位置及格式

qt.conf是一个ini格式的文件。QLibraryInfo将会从以下3个位置加载qt.conf文件:

利用Qt的资源系统从资源文件:/qt/etc/qt.conf处加载。

对于macOS,则是位于资源目录下的应用程序簇中。例如:

app/Contents/Resources/qt.conf。

包含应用程序的目录,例如:

QCoreApplication::applicationDirPath() + QDir::separator() + "qt.conf"

c结构体

static const struct {

char key[19], value[13];

} qtConfEntries[] = {

{ "Prefix", "." },

{ "Documentation", "doc" }, // should be ${Data}/doc

{ "Headers", "include" },

{ "Libraries", "lib" },

#ifdef Q_OS_WIN

{ "LibraryExecutables", "bin" },

#else

{ "LibraryExecutables", "libexec" }, // should be ${ArchData}/libexec

#endif

{ "Binaries", "bin" },

{ "Plugins", "plugins" }, // should be ${ArchData}/plugins

{ "Imports", "imports" }, // should be ${ArchData}/imports

{ "Qml2Imports", "qml" }, // should be ${ArchData}/qml

{ "ArchData", "." },

{ "Data", "." },

{ "Translations", "translations" }, // should be ${Data}/translations

{ "Examples", "examples" },

{ "Tests", "tests" },

#ifdef QT_BUILD_QMAKE

{ "Sysroot", "" },

{ "HostBinaries", "bin" },

{ "HostLibraries", "lib" },

{ "HostData", "." },

{ "TargetSpec", "" },

{ "HostSpec", "" },

{ "HostPrefix", "" },

#endif

};

覆盖路径

qt.conf文件能用来覆盖编译到Qt库中的硬编码路径,也就是1节提到的通过QLibraryInfo::location和QLibraryInfo::LibraryLocation获取到的路径。如果qt.conf中设置了这些路径,则通过QLibraryInfo::location和QLibraryInfo::LibraryLocation获取到的路径将不再是Qt安装时的默认路径,而是qt.conf中设置的这些路径。这在某些情况下会非常有用,如:如果没有qt.conf文件,则Qt库将会用默认硬编码路径去查找插件、翻译文件等路径,这些目录路径在某些目标系统上可能不存在或不能访问,在这种情况下,可以通过在qt.conf文件设置路径,让Qt从qt.conf设置的路径搜索。

qt.conf文件由路径组构成。每个组对应QLibraryInfo::LibraryLocation枚举即表1中的一个枚举值,如下:

节点 值

Prefix

QCoreApplication::applicationDirPath()

Documentation

doc

Headers

include

Libraries

lib

LibraryExecutables

libexec

Binaries

bin

Plugins

plugins

Imports

imports

Qml2Imports

qml

ArchData

.

Data

.

Translations

translations

Examples

examples

Tests

tests

Settings

.

相关推荐
十启树2 小时前
用Qt 对接‌百度AI平台
人工智能·qt·百度
DS小龙哥2 小时前
QT For Android开发-打开PPT文件
android·qt·powerpoint
锦亦之223312 小时前
QT+OSG+OSG-earth如何在窗口显示一个地球
开发语言·qt
柳鲲鹏15 小时前
编译成功!QT/6.7.2/Creator编译Windows64 MySQL驱动(MinGW版)
开发语言·qt·mysql
三玖诶15 小时前
如何在 Qt 的 QListWidget 中逐行添加和显示数据
开发语言·qt
阳光开朗_大男孩儿21 小时前
DBUS属性原理
linux·服务器·前端·数据库·qt
Alphapeople1 天前
Qt Modbus
开发语言·qt
竹林海中敲代码1 天前
Qt Creator 集成开发环境 常见问题
qt·qt工具常见问题
竹林海中敲代码1 天前
Qt安卓开发连接手机调试(红米K60为例)
android·qt·智能手机
长沙红胖子Qt1 天前
关于 Qt运行加载内存较大崩溃添加扩大运行内存 的解决方法
开发语言·qt·qt扩大运行内存