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.conf
文件来覆盖编译到 Qt XML 库中的硬编码路径。更多信息,请参阅使用 qt.conf文档。
另请参阅 QSysInfo 和Using 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()。
© 2025 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.