Add QLibraryInfo::version() returning the Qt version as QVersionNumber
[ChangeLog][QtCore][QLibraryInfo] Added QLibraryInfo::version(), which returns the current version of the Qt library as a QVersionNumber object. Change-Id: Ifea6e497f11a461db432ffff1448d4dc84ef57b1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
f05d5dfa85
commit
6dfc3541e6
@ -1033,7 +1033,7 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in
|
|||||||
example, "4.1.2"). This may be a different version than the
|
example, "4.1.2"). This may be a different version than the
|
||||||
version the application was compiled against.
|
version the application was compiled against.
|
||||||
|
|
||||||
\sa QT_VERSION_STR
|
\sa QT_VERSION_STR, QLibraryInfo::version()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char *qVersion() Q_DECL_NOTHROW
|
const char *qVersion() Q_DECL_NOTHROW
|
||||||
|
@ -366,6 +366,19 @@ QLibraryInfo::isDebugBuild()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef QT_BOOTSTRAPPED
|
||||||
|
/*!
|
||||||
|
\since 5.8
|
||||||
|
Returns the version of the Qt library.
|
||||||
|
|
||||||
|
\sa qVersion()
|
||||||
|
*/
|
||||||
|
QVersionNumber QLibraryInfo::version() Q_DECL_NOTHROW
|
||||||
|
{
|
||||||
|
return QVersionNumber(QT_VERSION_MAJOR, QT_VERSION_MINOR, QT_VERSION_PATCH);
|
||||||
|
}
|
||||||
|
#endif // QT_BOOTSTRAPPED
|
||||||
|
|
||||||
#endif // QT_BUILD_QMAKE
|
#endif // QT_BUILD_QMAKE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include <QtCore/qstring.h>
|
#include <QtCore/qstring.h>
|
||||||
#include <QtCore/qdatetime.h>
|
#include <QtCore/qdatetime.h>
|
||||||
|
#include <QtCore/qversionnumber.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -63,6 +64,10 @@ public:
|
|||||||
|
|
||||||
static bool isDebugBuild();
|
static bool isDebugBuild();
|
||||||
|
|
||||||
|
#ifndef QT_BOOTSTRAPPED
|
||||||
|
static QVersionNumber version() Q_DECL_NOTHROW Q_DECL_CONST_FUNCTION;
|
||||||
|
#endif
|
||||||
|
|
||||||
enum LibraryLocation
|
enum LibraryLocation
|
||||||
{
|
{
|
||||||
PrefixPath = 0,
|
PrefixPath = 0,
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
#include <QtCore/qversionnumber.h>
|
#include <QtCore/qversionnumber.h>
|
||||||
|
#include <QtCore/qlibraryinfo.h>
|
||||||
|
|
||||||
class tst_QVersionNumber : public QObject
|
class tst_QVersionNumber : public QObject
|
||||||
{
|
{
|
||||||
@ -79,6 +80,7 @@ private slots:
|
|||||||
void serialize_data();
|
void serialize_data();
|
||||||
void serialize();
|
void serialize();
|
||||||
void moveSemantics();
|
void moveSemantics();
|
||||||
|
void qtVersion();
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_QVersionNumber::singleInstanceData()
|
void tst_QVersionNumber::singleInstanceData()
|
||||||
@ -636,6 +638,17 @@ void tst_QVersionNumber::moveSemantics()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QVersionNumber::qtVersion()
|
||||||
|
{
|
||||||
|
QVersionNumber v = QLibraryInfo::version();
|
||||||
|
QVERIFY(!v.isNull());
|
||||||
|
QCOMPARE(v.majorVersion(), QT_VERSION_MAJOR);
|
||||||
|
// we can't compare the minor and micro version:
|
||||||
|
// the library may change without the test being recompiled
|
||||||
|
|
||||||
|
QCOMPARE(v.toString(), QString(qVersion()));
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_APPLESS_MAIN(tst_QVersionNumber)
|
QTEST_APPLESS_MAIN(tst_QVersionNumber)
|
||||||
|
|
||||||
#include "tst_qversionnumber.moc"
|
#include "tst_qversionnumber.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user