<QtVersionChecks> Proxy Page
|QT_VERSION_CHECK(major, minor, patch)|
This macro expands to a numeric value of the same form as QT_VERSION_CHECK() constructs, that specifies the version of Qt with which code using it is compiled. For example, if you compile your application with Qt 6.1.2, the QT_VERSION macro will expand to
0x060102, the same as
QT_VERSION_CHECK(6, 1, 2). Note that this need not agree with the version the application will find itself using at runtime.
You can use QT_VERSION to select the latest Qt features where available while falling back to older implementations otherwise. Using QT_VERSION_CHECK() for the value to compare with is recommended.
#if QT_VERSION >= QT_VERSION_CHECK(4, 1, 0) QIcon icon = style()->standardIcon(QStyle::SP_TrashIcon); #else QPixmap pixmap = style()->standardPixmap(QStyle::SP_TrashIcon); QIcon icon(pixmap); #endif
See also QT_VERSION_STR, QT_VERSION_CHECK(), and qVersion().
QT_VERSION_CHECK(major, minor, patch)
Turns the major, minor and patch numbers of a version into an integer that encodes all three. When expressed in hexadecimal, this integer is of form
0xMM == major,
0xNN == minor, and
0xPP == patch. This can be compared with another similarly processed version ID.
#include <QtGlobal> #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include <QtWidgets> #else #include <QtGui> #endif
Note: the parameters are read as integers in the normal way, so should normally be written in decimal (so a
0x prefix must be used if writing them in hexadecimal). Thus
QT_VERSION_CHECK(5, 15, 0) is equal to
0x050f00, which could equally be written
QT_VERSION_CHECK(5, 0xf, 0).
See also QT_VERSION.
© 2023 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.