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 key19, value13;

} 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

.

相关推荐
敲上瘾3 小时前
Qt控件通用属性:geometry、qrc资源到QSS样式表等
开发语言·c++·qt·ui
ShineWinsu4 小时前
对于Qt:QFontDialog的解析
c++·qt·面试·gui·字体·客户端·qfontdialog
JosieBook9 小时前
【鸿蒙】把一个 Qt 桌面视频编辑器“搬“上鸿蒙 PC:Olive 移植适配全记录
qt·音视频·harmonyos
Lucas. Wáng1 天前
Qt学习之旅
c++·qt
金色熊族2 天前
qt5.15.9编译qt-creator7.0.2源码
linux·qt
ShineWinsu2 天前
对于Qt:QMessageBox的解析
开发语言·c++·qt·面试·客户端·qmessagebox·消息对话框
宏笋3 天前
Qt开发了一款绘图和制作信笺的软件
qt
半杯咖啡半行码3 天前
Qt 隐式共享(Implicit Sharing)深度解析:机制、陷阱与 Qt6迁移
开发语言·数据库·qt
慧都产品智能化4 天前
Qt 开发 CAD/CAM 工序表的隐性成本分析
c++·qt·qt5·qt6.3
ShineWinsu5 天前
对于Qt窗口:QMainWindow、QMenuBar、Qmenu、QAction的解析
c++·qt·菜单·qmainwindow·qaction·qmenu·qmenubar