aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsapi
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-01-03 12:20:33 +0100
committerUlf Hermann <ulf.hermann@qt.io>2023-01-03 14:44:57 +0100
commitb62f70fe9fd36252e9ae31e910323a130f458ddd (patch)
treecc177070571eb676696a3e0f9bcaa352a570c455 /src/qml/jsapi
parent179200d2a3fa0df28fbf3790f8ff1ee47d0926c0 (diff)
QJSEngine: Document new conversion functions
... and drop the notes about QMetaType<T>. You can get a metatype for any type these days. Pick-to: 6.5 Change-Id: Iaae53830dfb9cbe81975c3f73cf6cbe33494884a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/jsapi')
-rw-r--r--src/qml/jsapi/qjsengine.cpp44
1 files changed, 38 insertions, 6 deletions
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp
index d9a2abd3a9..54efde52d7 100644
--- a/src/qml/jsapi/qjsengine.cpp
+++ b/src/qml/jsapi/qjsengine.cpp
@@ -956,24 +956,57 @@ QString QJSEngine::convertQObjectToString(QObject *object)
/*! \fn template <typename T> QJSValue QJSEngine::toScriptValue(const T &value)
Creates a QJSValue with the given \a value.
- This works with any type \c{T} that has a \c{QMetaType}.
\sa fromScriptValue(), coerceValue()
*/
+/*! \fn template <typename T> QJSManagedValue QJSEngine::toManagedValue(const T &value)
+
+ Creates a QJSManagedValue with the given \a value.
+
+ \sa fromManagedValue(), coerceValue()
+*/
+
+/*! \fn template <typename T> QJSPrimitiveValue QJSEngine::toPrimitiveValue(const T &value)
+
+ Creates a QJSPrimitiveValue with the given \a value.
+
+ Since QJSPrimitiveValue can only hold int, bool, double, QString, and the
+ equivalents of JavaScript \c null and \c undefined, the value will be
+ coerced aggressively if you pass any other type.
+
+ \sa fromPrimitiveValue(), coerceValue()
+*/
+
/*! \fn template <typename T> T QJSEngine::fromScriptValue(const QJSValue &value)
Returns the given \a value converted to the template type \c{T}.
- This works with any type \c{T} that has a \c{QMetaType}.
\sa toScriptValue(), coerceValue()
*/
+/*! \fn template <typename T> T QJSEngine::fromManagedValue(const QJSManagedValue &value)
+
+ Returns the given \a value converted to the template type \c{T}.
+
+ \sa toManagedValue(), coerceValue()
+*/
+
+/*! \fn template <typename T> T QJSEngine::fromPrimitiveValue(const QJSPrimitiveValue &value)
+
+ Returns the given \a value converted to the template type \c{T}.
+
+ Since QJSPrimitiveValue can only hold int, bool, double, QString, and the
+ equivalents of JavaScript \c null and \c undefined, the value will be
+ coerced aggressively if you request any other type.
+
+ \sa toPrimitiveValue(), coerceValue()
+*/
+
/*! \fn template <typename T> T QJSEngine::fromVariant(const QVariant &value)
Returns the given \a value converted to the template type \c{T}.
- This works with any type \c{T} that has a \c{QMetaType}. The
- conversion is done in JavaScript semantics. Those differ from
+ The conversion is done in JavaScript semantics. Those differ from
qvariant_cast's semantics. There are a number of implicit
conversions between JavaScript-equivalent types that are not
performed by qvariant_cast by default.
@@ -984,8 +1017,7 @@ QString QJSEngine::convertQObjectToString(QObject *object)
/*! \fn template <typename From, typename To> T QJSEngine::coerceValue(const From &from)
Returns the given \a from converted to the template type \c{To}.
- This works with any type \c{T} that has a \c{QMetaType}. The
- conversion is done in JavaScript semantics. Those differ from
+ The conversion is done in JavaScript semantics. Those differ from
qvariant_cast's semantics. There are a number of implicit
conversions between JavaScript-equivalent types that are not
performed by qvariant_cast by default. This method is a generalization of