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

.

相关推荐
云小逸5 小时前
【 VS2013 集成 Qt5.7.1 踩坑记录:moc/uic/rcc 报“系统找不到指定的路径”怎么解决?】
开发语言·windows·qt
努力努力再努力wz6 小时前
【Qt入门系列】深入理解信号与槽:从事件响应到自定义信号机制
c语言·开发语言·数据结构·数据库·c++·qt·mysql
mengzhi啊6 小时前
串口数据监控软件开发总结
qt
小短腿的代码世界6 小时前
Qwt实时FFT频谱分析深度解析:从信号采集到可视化渲染的完整架构设计
前端·qt·架构·交互
Hua-Jay6 小时前
OpenCV联合C++/Qt 学习笔记(二十)----Harri角点检测、Shi-Tomas角点检测及亚像素级别角点位置优化
c++·笔记·qt·opencv·学习·计算机视觉
十五年专注C++开发6 小时前
QFluentKit: 一个基于 Qt Widgets 的 Fluent Design 风格 UI 组件库
开发语言·c++·qt·ui·qfluentkit
Hua-Jay6 小时前
OpenCV联合C++/Qt 学习笔记(十九)----图像分割
c++·笔记·qt·opencv·学习
小短腿的代码世界7 小时前
Qt位置服务深度解析:从GPS定位到地理围栏的完整架构设计
开发语言·qt
史迪仔01127 小时前
[QML] Qt5/6图像色彩空间处理
开发语言·前端·c++·qt
小短腿的代码世界7 小时前
传感器暗战:Qt Sensors如何让桌面应用“感知“物理世界?
开发语言·qt