[Interest] [interest] Getting QMetaProperty for a dynamically added property

Prashant prashant.me at gmail.com
Tue Jun 4 07:59:25 CEST 2013


I need to come up with a property browser (for dynamic properties) like
interface table for QObject derived class objects. Properties can be
enumerated using QObject::dynamicPropertyNames() function. For each entry,
I intend to read the property from the object using QObject:roperty(). That
will take care of the reading part.
For modifying data, I need to depend on the type of variant returned by
QObject:roperty() and set the delegate appropriately for the type. Here
comes the problem with enumeration types. For enum, I want to have a
delegate which shows a combo box with all the enumeration value strings.
For Q_Property like properties(lets call it static properties), I can
access the metaObject(), determine whether enum, get the QMetaEnum using
QMetaProp::enumerator() and get it done easily.
However, dynamic properties the QVariant 1st problem is type is int for the
enums. I can overcome that by Q_Declare_MetaType(SomeClass::EnumName) and
qRegisterMetaType<SomeClass::EnumName>("nameMyEnum ").
Now the QVariant I get from QObject:roperty() will give the type as
"nameMyEnum" rather than int.
But how do i get the QMetaEnum so that I can get all the related enum
values and populate the combo box.
-- 
Prashant
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130604/0df54617/attachment.html>


More information about the Interest mailing list