diff options
-rw-r--r-- | src/corelib/global/qflags.h | 3 | ||||
-rw-r--r-- | src/corelib/global/qglobal.cpp | 18 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h index 8d538c97f4..0e20f88c9c 100644 --- a/src/corelib/global/qflags.h +++ b/src/corelib/global/qflags.h @@ -112,6 +112,9 @@ public: constexpr inline QFlags(std::initializer_list<Enum> flags) noexcept : i(initializer_list_helper(flags.begin(), flags.end())) {} + constexpr static inline QFlags fromInt(Int i) noexcept { return QFlags(QFlag(i)); } + constexpr inline Int toInt() const noexcept { return i; } + constexpr inline QFlags &operator&=(int mask) noexcept { i &= mask; return *this; } constexpr inline QFlags &operator&=(uint mask) noexcept { i &= mask; return *this; } constexpr inline QFlags &operator&=(Enum mask) noexcept { i &= Int(mask); return *this; } diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 95f5adab3b..dea3b30a29 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -498,6 +498,24 @@ static_assert(sizeof(qint64) == 8, "Internal error, qint64 is misdefined"); */ /*! + \fn template <typename Enum> QFlags<Enum> QFlags<Enum>::fromInt(Int i) noexcept + \since 6.2 + + Constructs a QFlags object representing the integer value \a i. +*/ + +/*! + \fn template <typename Enum> Int QFlags<Enum>::toInt() const noexcept + \since 6.2 + + Returns the value stored in the QFlags object as an integer. Note + that the returned integer may be signed or unsigned, depending on + whether the enum's underlying type is signed or unsigned. + + \sa Int +*/ + +/*! \macro Q_DISABLE_COPY(Class) \relates QObject |