PDA

View Full Version : Q_PROPERTY with QObject?



lni
4th January 2013, 07:49
Hi,

My class is not derived from QObject, how can I still use Q_PROPERTY macro? I did the following:



class MyClass
{
Q_GADGET
Q_PROPERTY( ...... )

};


The moc system recognizes Q_GADGET tag and generates staticMetaObject, as well as those property names registered with Q_PROPERTY, but I can't use the QMetaProperty::read method to read the property value, as it expects QObject. Is there a way to work around (without sub-class from QObject)?

Thanks!

wysota
4th January 2013, 09:51
No, I don't think so. Q_GADGET only implements meta-type part of QObject functionality so that you can register flags, enums, etc. It's not a real QObject.