From e7e7540aecc5a4a44f1d1a25e58ccbcf662cbe24 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 27 Jul 2020 17:00:22 +0200 Subject: Deprecate int based convert/canConvert Better to provide the correct meta type to convert to. Change-Id: I8e0d46e4ba482186201c157e302c03874bd38e7b Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/corelib/kernel/qvariant.h') diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 9ce12ad1b2..48ea3a9a03 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -249,8 +249,18 @@ class Q_CORE_EXPORT QVariant const char *typeName() const; QMetaType metaType() const; - bool canConvert(int targetTypeId) const; - bool convert(int targetTypeId); + bool canConvert(QMetaType targetType) const + { return QMetaType::canConvert(d.type(), targetType); } + bool convert(QMetaType type); + +#if QT_DEPRECATED_SINCE(6, 0) + QT_DEPRECATED_VERSION_6_0 + bool canConvert(int targetTypeId) const + { return QMetaType::canConvert(d.type(), QMetaType(targetTypeId)); } + QT_DEPRECATED_VERSION_6_0 + bool convert(int targetTypeId) + { return convert(QMetaType(targetTypeId)); } +#endif inline bool isValid() const; bool isNull() const; @@ -376,7 +386,7 @@ class Q_CORE_EXPORT QVariant template bool canConvert() const - { return canConvert(qMetaTypeId()); } + { return canConvert(QMetaType::fromType()); } public: struct PrivateShared -- cgit v1.2.3