Details
-
Suggestion
-
Resolution: Fixed
-
P2: Important
-
None
-
-
3ad9f94ff (dev), c7fd6628d (dev), a09ea6b3d (dev), af76a73c5 (dev)
Description
This suggestion is a follow up to this thread on the devel mailing list: https://lists.qt-project.org/pipermail/development/2021-October/041841.html
Ulf wrote:
"you can add a static create() function that takes a QJSValue as argument to your class or have a ctor that takes QJSValue. Then register the type using QML_ANONYMOUS and it should be possible to create it from any JavaScript value assigned to it."
Unfortunately the registered createValueTypeFunc gets only called for a hardcoded selection of types: see QQmlObjectCreator::setPropertyValue. Actually these types correspond to what can be found in qquickvaluetypes_p.h.
To me it looks like almost everything is in place to allow application code to customize the creation of value types - beside doing the very final step in QQmlObjectCreator::setPropertyValue.
What I would like to see is that QQmlObjectCreator::setPropertyValue would always call createValueTypeFunc in case one has been registered for the value type.
Attachments
Issue Links
- resulted in
-
QTBUG-108879 Constructing, copying and moving objects using QVariant/QMetaType/QMetaObject is incomplete
- Closed