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
For Gerrit Dashboard: QTBUG-108789 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
445237,4 | QML: Fix casting between builtin types when constructing value types | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
457088,16 | Avoid duplicate value type creation | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
461378,5 | qmltyperegistrar: Propagate information on value type ctors | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
461551,2 | QVariant: Move some inline methods into a private header | dev | qt/qtbase | Status: MERGED | +2 | 0 |
462016,5 | Add cast operators to all our "extended" value types | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |