[Development] Qt 6.2 QQmlMetaType incompatibility

Ulf Hermann ulf.hermann at qt.io
Wed Oct 6 18:08:08 CEST 2021


Hi Uwe,

>> 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. 

> Couldn't get something running
> with this approach. But as I'm using my class as property and the
> docs state that this is not possible with classes being declared as
> QML_ANONYMOUS I gave up.

What part of the docs do you mean here? You can very well have anonymous
value types as C++-declared properties of other types. It may be that 
we're still missing some bits and pieces for the creation from JS values 
to work. So far the approach is only used by the QtQuick value types. 
Some of those are indeed anonymous, but all of them happen to use the 
foreign/extended hack. It should also work without that hack, though. 
Feel free to open a bug report or submit a patch.

best regards,
Ulf


More information about the Development mailing list