diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-09-08 14:41:42 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2022-09-24 07:54:29 +0000 |
commit | 3195b44e1c9678584c05ed823aab2eb32518d868 (patch) | |
tree | 7c13d0ee0b6f9074841862e160d19d744daeda58 /src/qml/qml/qqmlglobal_p.h | |
parent | b101be9be64b6cc82dc357da0faeffbaab771b8f (diff) |
Allow more options for creating value types from JS objects
We allow value types to be created
1. by calling Q_INVOKABLE constructors
2. by setting their values from properties of a JS object
Both have to be opted into by setting a class info. If opted into, these
options override the existing methods. When a a type can be created by
setting its properties, that implies you can also initialize it using an
invokable constructor. However, when given a JS object, the properties
method is used.
We keep this internal and undocumented for now. As the last try (the
create(QJSValue) methods and QJSValue ctors) was not that stellar, let's
first wait a bit and see if we're getting it right this time around.
Fixes: QTBUG-106480
Change-Id: I767230924afcba032d501846cc3263dad57b7bf0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlglobal_p.h')
-rw-r--r-- | src/qml/qml/qqmlglobal_p.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlglobal_p.h b/src/qml/qml/qqmlglobal_p.h index 0d22cc2de7..f7a50e8350 100644 --- a/src/qml/qml/qqmlglobal_p.h +++ b/src/qml/qml/qqmlglobal_p.h @@ -185,7 +185,12 @@ inline void QQml_setParent_noEvent(QObject *object, QObject *parent) class QQmlValueTypeProvider { public: - static bool createValueType(QMetaType, const QJSValue &, QVariant &); + static bool constructFromJSValue(const QJSValue &, QMetaType, void *); + + static bool createValueType(const QString &, QMetaType, void *); + static bool createValueType(const QJSValue &, QMetaType, void *); + static bool createValueType(const QV4::Value &, QMetaType, void *); + static bool createValueType(const QVariant &, QMetaType, void *); }; class Q_QML_PRIVATE_EXPORT QQmlColorProvider |