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>
This commit is contained in:
Thiago Macieira 2022-10-06 09:01:15 -07:00 committed by Qt Cherry-pick Bot
parent 5642f64843
commit 3ae6b28369

View File

@ -1403,8 +1403,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()
*/
@ -1954,9 +1959,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()
*/