IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

<QtVersionChecks>

Qt Core Reference Documentation.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

I. Macro Documentation

 

I-1. QT_VERSION

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:

 
Sélectionnez
#if QT_VERSION &gt;= QT_VERSION_CHECK(4, 1, 0)
    QIcon icon = style()-&gt;standardIcon(QStyle::SP_TrashIcon);
#else
    QPixmap pixmap = style()-&gt;standardPixmap(QStyle::SP_TrashIcon);
    QIcon icon(pixmap);
#endif

I-1-1. See Also

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

Example:

 
Sélectionnez
#include &lt;QtGlobal&gt;

#if QT_VERSION &gt;= QT_VERSION_CHECK(5, 0, 0)
#include &lt;QtWidgets&gt;
#else
#include &lt;QtGui&gt;
#endif

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).

I-2-1. See Also

See also QT_VERSION

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+