今天看到Qt的一个类QLibraryInfo,看下源码如下:
#ifndef QLIBRARYINFO_H
#define QLIBRARYINFO_H
#include <QtCore/qstring.h>
#include <QtCore/QDate>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Core)
#ifndef QT_NO_SETTINGS
class Q_CORE_EXPORT QLibraryInfo
{
public:
static QString licensee();
static QString licensedProducts();
static QString buildKey();
#ifndef QT_NO_DATESTRING
static QDate buildDate();
#endif //QT_NO_DATESTRING
enum LibraryLocation
{
PrefixPath,
DocumentationPath,
HeadersPath,
LibrariesPath,
BinariesPath,
PluginsPath,
DataPath,
TranslationsPath,
SettingsPath,
DemosPath,
ExamplesPath,
ImportsPath
};
static QString location(LibraryLocation); // ### Qt 5: consider renaming it to path()
private:
QLibraryInfo();
};
#endif /* QT_NO_SETTINGS */
QT_END_NAMESPACE
QT_END_HEADER
#endif // QLIBRARYINFO_H
这个类的介绍就是返回Qt的目录信息,在designer里用到了static QString location(LibraryLocation);这个函数,源码是QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
结果返回了Qt的翻译转换文件目录D:\QT\4.7.3\translations,这里我试着把其他的宏看了一遍如下:
QLibraryInfo::PrefixPath :D:\QT\4.7.3
QLibraryInfo::DocumentationPath:D:\QT\4.7.3\doc
QLibraryInfo::HeadersPath:D:\QT\4.7.3\include
QLibraryInfo::LibrariesPath:D:\QT\4.7.3\lib
QLibraryInfo::BinariesPath:D:\QT\4.7.3\bin
QLibraryInfo::PluginsPath:D:\Qt\4.7.3\plugins
QLibraryInfo::ImportsPath:D:\Qt\4.7.3\imports
QLibraryInfo::DataPath:D:\Qt\4.7.3
QLibraryInfo::SettingsPath:D:\Qt\4.7.3
QLibraryInfo::ExamplesPath:D:\Qt\4.7.3\examples
QLibraryInfo::DemosPath:D:\Qt\4.7.3\demos
QLibraryInfo::buildDate()是Qt源码编译的时间,我这里是2011-5-9,
写代码验证了一下,如下:
QDate date = QLibraryInfo::buildDate();
QString ss = QString("%1-%2-%3").arg(date.year()).arg(date.month()).arg(date.day());
QLibraryInfo::buildKey():编译Qt的平台,编译器和configure的信息,我这里全编译所以结果就是下面的:
Windows msvc debug full-config
平台 编译器 编译结果类型 configure全部
QLibraryInfo::licensedProducts():返回Qt的license产品信息,提示结果:FullFramework
QLibraryInfo::licensee():返回Qt的license信息,我这里是Zhu Jian