[Interest] how can I call qRegisterMetaType?

Hamish Moffatt hamish at risingsoftware.com
Tue May 17 09:04:57 CEST 2016


On 17/05/16 13:42, Thiago Macieira wrote:
> On terça-feira, 17 de maio de 2016 11:41:59 PDT Hamish Moffatt wrote:
>> It seems that for a metatype that is a QList<MyClass::MyEnum> I must
>> call qRegisterMetaType with the name specified, else reading properties
>> complains that the metatype isn't registered. What worries me is that
>> the type name must be specified without the class, as in
>>
>> qRegisterMetaType<QList<MyClass::MyEnum>>("QList<MyEnum>");
>>
>> If I have another enum MyOtherClass::MyEnum am I going to have collisions?
> Yes.
>
> Always register metatypes with their full names, always use the full name in
> signals and slots. That's what happens when string comparisons are used.
>

But, as per my example code,

qRegisterMetaType<QList<MyClass::MyEnum>>("QList<MyClass::MyEnum>");


doesn't work; QMetaProperty::read prints

QMetaProperty::read: Unable to handle unregistered datatype 'QList<MyEnum>' for property 'MyClass::myEnumList'

ie it can't find the type.


Hamish




More information about the Interest mailing list