[Development] Qt 6.2 QQmlMetaType incompatibility

Ulf Hermann ulf.hermann at qt.io
Mon Sep 27 10:36:13 CEST 2021


instead of using QQmlMetaType::registerCustomStringConverter() 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.

You can also do a number of interesting and nasty things to wrap the 
existing QMarginsF into a value type. Take a look at 
qquickvaluetypes_p.h in qtdeclarative for "inspiration".

The only thing shown there that you cannot do to your own value types is 
giving them names. The names passed to QML_VALUE_TYPE() are only 
decoration so far because the actual name resolution for value types is 
still hardcoded.

best regards,

More information about the Development mailing list