Warning

This section contains snippets that were automatically translated from C++ to Python and may contain errors.

Macros for performing Qt version checks.

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.

Example:

#if QT_VERSION >= QT_VERSION_CHECK(4, 1, 0)
    icon = style().standardIcon(QStyle.SP_TrashIcon)
#else
    pixmap = style().standardPixmap(QStyle.SP_TrashIcon)
    icon = QIcon(pixmap)
#endif

See also

QT_VERSION_STR QT_VERSION_CHECK() qVersion()

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 0xMMNNPP wherein 0xMM == major, 0xNN == minor, and 0xPP == patch. This can be compared with another similarly processed version ID.

Example:

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
from PySide6 import QtWidgets
#else
from PySide6 import 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