From 276d633626ea9a52dc5d28b9dafbfa5345f35521 Mon Sep 17 00:00:00 2001 From: Sze Howe Koh Date: Fri, 21 Feb 2014 22:31:51 +0800 Subject: Doc: Clarify QJsonValue::fromVariant() type conversions It wasn't obvious before that many QMetaType types get converted to the same QJsonValue type. Change-Id: I7bb02cb10b6c8a873e291cdf1e16c6c821d51208 Reviewed-by: Jerome Pasion Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/corelib/json/qjsonvalue.cpp | 52 +++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 12 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/json/qjsonvalue.cpp b/src/corelib/json/qjsonvalue.cpp index 487a431b8f..e5194f7336 100644 --- a/src/corelib/json/qjsonvalue.cpp +++ b/src/corelib/json/qjsonvalue.cpp @@ -343,18 +343,46 @@ QJsonValue &QJsonValue::operator =(const QJsonValue &other) The conversion will convert QVariant types as follows: - \list - \li QMetaType::Bool to Bool - \li QMetaType::Int - \li QMetaType::Double - \li QMetaType::LongLong - \li QMetaType::ULongLong - \li QMetaType::UInt to Double - \li QMetaType::QString to String - \li QMetaType::QStringList - \li QMetaType::QVariantList to Array - \li QMetaType::QVariantMap to Object - \endlist + \table + \header + \li Source type + \li Destination type + \row + \li + \list + \li QMetaType::Bool + \endlist + \li QJsonValue::Bool + \row + \li + \list + \li QMetaType::Int + \li QMetaType::UInt + \li QMetaType::LongLong + \li QMetaType::ULongLong + \li QMetaType::Double + \endlist + \li QJsonValue::Double + \row + \li + \list + \li QMetaType::QString + \endlist + \li QJsonValue::String + \row + \li + \list + \li QMetaType::QStringList + \li QMetaType::QVariantList + \endlist + \li QJsonValue::Array + \row + \li + \list + \li QMetaType::QVariantMap + \endlist + \li QJsonValue::Object + \endtable For all other QVariant types a conversion to a QString will be attempted. If the returned string is empty, a Null QJsonValue will be stored, otherwise a String value using the returned QString. -- cgit v1.2.3