summaryrefslogtreecommitdiff
path: root/src/qml/jsapi/qjsvalue.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-12-07 15:04:44 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-12-07 15:53:39 +0100
commit61a5860599cb2bf770ea3150f8a993d3b08b840a (patch)
tree266eaafa852e5a95622a8fb0a571d5f3ab2eb39c /src/qml/jsapi/qjsvalue.h
parente8596de70e46e98a851ac8204e294e5ef4994b96 (diff)
downloadqtdeclarative-61a5860599cb2bf770ea3150f8a993d3b08b840a.tar.gz
QJSValue: Add toVariant() overload with conversion behavior
The QJSValue to QVariant conversion is traditionally messy. The recent addition of a special case for FunctionObject did not make that better. Rather, we now add a way of specifying that the conversion should be lossless, which avoids all conversions of JS objects and arrays. Amends commit 6b08c24297f39f3c67bc5c16f46198b33af66529. Change-Id: I6d4506b52d3175ed2f2984f8a26d560cf6311ab6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsapi/qjsvalue.h')
-rw-r--r--src/qml/jsapi/qjsvalue.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/qml/jsapi/qjsvalue.h b/src/qml/jsapi/qjsvalue.h
index 8a62b974c8..ad3c4ffd4d 100644
--- a/src/qml/jsapi/qjsvalue.h
+++ b/src/qml/jsapi/qjsvalue.h
@@ -79,6 +79,11 @@ public:
URIError
};
+ enum ObjectConversionBehavior {
+ ConvertJSObjects,
+ RetainJSObjects
+ };
+
public:
QJSValue(SpecialValue value = UndefinedValue);
~QJSValue();
@@ -121,7 +126,10 @@ public:
qint32 toInt() const;
quint32 toUInt() const;
bool toBool() const;
+
QVariant toVariant() const;
+ QVariant toVariant(ObjectConversionBehavior behavior) const;
+
QObject *toQObject() const;
const QMetaObject *toQMetaObject() const;
QDateTime toDateTime() const;