summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-10-06 09:01:15 -0700
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-10-11 21:44:24 +0000
commit50f67dcd5493b59b40f613d4eacfe62154126363 (patch)
tree52e875d59133163677a761d9066bd5da24f45b25
parentFix broken Text rendering when noantialiased NativeRendering is used (diff)
downloadqtbase-50f67dcd5493b59b40f613d4eacfe62154126363.tar.xz
qtbase-50f67dcd5493b59b40f613d4eacfe62154126363.zip
QVariant/Doc: expand what toList & toMap conversions may succeed
I don't know when conversion through sequential and associative iteratables was added, probably some time in the 5.x. QString and QByteArray got conversions to sequential iteratables for Qt 6.1 with commit c9a11022692f9a4bd36beb0cd001686694a48915. Since that was intentional, I'm just documenting reality. Fixes: QTBUG-107246 Change-Id: Id8d5e3999fe94b03acc1fffd171b863b1a0ead68 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit 49e62c51f275c94501a3c42b8fbd8f11b87e9d41) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/corelib/kernel/qvariant.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 0f1a572a83..e96272572c 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1423,8 +1423,13 @@ QString QVariant::toString() const
}
/*!
- Returns the variant as a QMap<QString, QVariant> if the variant
- has type() \l QMetaType::QVariantMap; otherwise returns an empty map.
+ Returns the variant as a QVariantMap if the variant has type() \l
+ QMetaType::QVariantMap. If it doesn't, QVariant will attempt to
+ convert the type to a map and then return it. This will succeed for
+ any type that has registered a converter to QVariantMap or which was
+ declared as a associative container using
+ \l{Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE}. If none of those
+ conditions are true, this function will return an empty map.
\sa canConvert(), convert()
*/
@@ -1974,9 +1979,13 @@ qreal QVariant::toReal(bool *ok) const
}
/*!
- Returns the variant as a QVariantList if the variant has userType()
- \l QMetaType::QVariantList or \l QMetaType::QStringList; otherwise returns
- an empty list.
+ Returns the variant as a QVariantList if the variant has userType() \l
+ QMetaType::QVariantList. If it doesn't, QVariant will attempt to convert
+ the type to a list and then return it. This will succeed for any type that
+ has registered a converter to QVariantList or which was declared as a
+ sequential container using \l{Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE}. If
+ none of those conditions are true, this function will return an empty
+ list.
\sa canConvert(), convert()
*/