[Qt-interest] qRegisterMetaType and namespaces
Andre Somers
andre at familiesomers.nl
Fri Sep 4 12:22:00 CEST 2009
Girish Ramakrishnan wrote:
> Hi Andre,
> Have you tried
> qRegisterMetaType<SelectionPolicyFlags>("SelectionPolicyFlags"); ?
>
>
Thanks, Girish! I had not tried that variation before, and it works :-)
Great.
Next up: figuring out where and how to use the Q_FLAGS macro to make the
meta property system work with this flag...
André
> Girish
>
> Andre Somers wrote:
>
>> Hi,
>>
>> I must be missing some simple...
>>
>> I am working on a set of classes that have been wrapped in a namespace.
>> Contained within this namespace is an enum type, that is then used with
>> Q_DECLARE_FLAGS to create a nice set of flags. I am thus ending up with
>> a SelectionPolicyFlags type.
>> One of the classes has Q_PROPERTY defined of that type. I know that in
>> order to make this work, I need to call Q_DECLARE_METATYPE for this
>> type, outside the namespace itself. That works. However, I also need to
>> call qRegisterMetaType<SelectionPolicyFlags>() for them to be usefull in
>> the Qt property system (and in queued signal/slots). It is there I am
>> running in to a problem. While the registering itself seems to work (I
>> have inserted a debug statement that outputs the type id that is
>> assigned), actually using it in the property does not. When trying to
>> access the property, I am getting the following output:
>>
>> QMetaProperty::read: Unable to handle unregistered datatype
>> 'SelectionPropertyFlags' for property
>> 'PropertyEditor::PropertyEditor::selectionPolicy'.
>>
>> Notice that there is a class PropertyEditor inside the namespace
>> PropertyEditor.
>>
>> I have made sure that the qRegisterMetaType is executed first by putting
>> this in the header:
>>
>> inline int init() {
>> qDebug() << qRegisterMetaType<SelectionPolicyFlags>();
>> return 0;
>> }
>> static int property_editor_init_dummy = init();
>>
>> I am a bit lost here. How can I make use of my flags with the Qt
>> Property system?
>>
>> André
>>
>
>
>
>
More information about the Qt-interest-old
mailing list