path: root/src/corelib/global/qflags.h
diff options
authorAllan Sandfeld Jensen <>2019-11-18 17:01:26 +0100
committerAllan Sandfeld Jensen <>2019-11-20 19:43:38 +0100
commitaf2daafde72db02454d24b7d691aa6861525ab99 (patch)
treeb59c47baf8af94a6ace5cbf4338944272e40e32b /src/corelib/global/qflags.h
parent8bc4ea1e97c138034d08c705a75f75763361400b (diff)
Deprecate constructing QFlags from a pointer
This was used to support QFlags f = 0 initialization, but with 0 used as a pointer literal now considered bad form, it had been changed many places to QFlags f = nullptr, which is meaningless and confusing. Change-Id: I4bc592151c255dc5cab1a232615caecc520f02e8 Reviewed-by: Thiago Macieira <>
Diffstat (limited to 'src/corelib/global/qflags.h')
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
index bd3c219968..4f46de5eaa 100644
--- a/src/corelib/global/qflags.h
+++ b/src/corelib/global/qflags.h
@@ -93,8 +93,10 @@ class QFlags
"long long will overflow.");
Q_STATIC_ASSERT_X((std::is_enum<Enum>::value), "QFlags is only usable on enumeration types.");
struct Private;
typedef int (Private::*Zero);
template <typename E> friend QDataStream &operator>>(QDataStream &, QFlags<E> &);
template <typename E> friend QDataStream &operator<<(QDataStream &, QFlags<E>);
@@ -115,8 +117,11 @@ public:
Q_DECL_CONSTEXPR inline QFlags(const QFlags &other);
Q_DECL_CONSTEXPR inline QFlags &operator=(const QFlags &other);
+ Q_DECL_CONSTEXPR inline QFlags() noexcept : i(0) {}
Q_DECL_CONSTEXPR inline QFlags(Enum flags) noexcept : i(Int(flags)) {}
- Q_DECL_CONSTEXPR inline QFlags(Zero = nullptr) noexcept : i(0) {}
+ QT_DEPRECATED_X("Use default constructor instead") Q_DECL_CONSTEXPR inline QFlags(Zero) noexcept : i(0) {}
Q_DECL_CONSTEXPR inline QFlags(QFlag flag) noexcept : i(flag) {}
Q_DECL_CONSTEXPR inline QFlags(std::initializer_list<Enum> flags) noexcept