QLibraryInfo Class
QLibraryInfo 类提供了有关 Qt 库的信息。更多内容...
| 头文件: | #include <QLibraryInfo> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
公共类型
| enum | LibraryPath { PrefixPath, DocumentationPath, HeadersPath, LibrariesPath, LibraryExecutablesPath, …, SettingsPath } |
静态公共成员
| bool | isDebugBuild() |
(since 6.5) bool | isSharedBuild() |
(since 6.0) QString | path(QLibraryInfo::LibraryPath p) |
(since 6.8) QStringList | paths(QLibraryInfo::LibraryPath p) |
| QVersionNumber | version() |
详细说明
该类提供了一个抽象,用于访问应用程序所使用的 Qt 库的相关信息,例如运行时路径或 Qt 库的构建配置。
默认的运行时路径取决于 Qt 构建配置,以及 Qt 库是否已被重定位,以及是否可能与应用程序捆绑在一起。
如果您的部署情况与默认情况不符,可以使用qt.conf 文件来覆盖默认路径。有关更多信息,请参阅“使用 qt.conf”文档。
另请参阅《 QSysInfo 》 和《使用 qt.conf》。
成员类型文档
enum QLibraryInfo::LibraryPath
此枚举类型用于查询特定路径:
| 常量 | 值 | 描述 |
|---|---|---|
QLibraryInfo::PrefixPath | 0 | 所有路径的默认前缀。 |
QLibraryInfo::DocumentationPath | 1 | 安装时的文档路径。 |
QLibraryInfo::HeadersPath | 2 | 所有头文件的路径。 |
QLibraryInfo::LibrariesPath | 3 | 已安装库的路径。 |
QLibraryInfo::LibraryExecutablesPath | 4 | 库在运行时所需已安装可执行文件的路径。 |
QLibraryInfo::BinariesPath | 5 | 已安装 Qt 二进制文件(工具和应用程序)的路径。 |
QLibraryInfo::PluginsPath | 6 | 已安装 Qt 插件的路径。 |
QLibraryInfo::QmlImportsPath | 7 | 要导入的已安装 QML 扩展的路径。 |
QLibraryInfo::Qml2ImportsPath | QmlImportsPath | 此值已弃用。请改用 QmlImportsPath。 |
QLibraryInfo::ArchDataPath | 8 | 指向一般架构相关 Qt 数据的路径。 |
QLibraryInfo::DataPath | 9 | 通用架构无关 Qt 数据的路径。 |
QLibraryInfo::TranslationsPath | 10 | Qt 字符串的翻译信息路径。 |
QLibraryInfo::ExamplesPath | 11 | 安装时的示例路径。 |
QLibraryInfo::TestsPath | 12 | 已安装的 Qt 测试用例的路径。 |
QLibraryInfo::SettingsPath | 100 | Qt 设置的路径。不适用于 Windows。 |
另请参阅 path()。
成员函数文档
[static noexcept] bool QLibraryInfo::isDebugBuild()
如果该 Qt 构建版本是在启用调试的情况下构建的,则返回 `true `;如果是发布模式下构建的,则返回 `false`。
[static noexcept, since 6.5] bool QLibraryInfo::isSharedBuild()
如果这是 Qt 的共享(动态)构建版本,则返回 `true `。
该函数在 Qt 6.5 中引入。
[static, since 6.0] QString QLibraryInfo::path(QLibraryInfo::LibraryPath p)
返回由p 指定的路径。
如果 qt.conf 中列出了多个路径,则仅返回第一个。
该函数于 Qt 6.0 版本中引入。
另请参阅 paths 。
[static, since 6.8] QStringList QLibraryInfo::paths(QLibraryInfo::LibraryPath p)
返回由p 指定的所有路径。
该函数在 Qt 6.8 中引入。
另请参阅 path 。
[static noexcept] QVersionNumber QLibraryInfo::version()
返回 Qt 库的版本号。
另请参阅 qVersion()。
© 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.