0

Imagine a QObject derived class:

class MyObject : public QObject
{
    Q_OBJECT;
    Q_PROPERTY(bool myBool READ myBool WRITE setMyBool);
    //...
}

How do I receive all the properties of the derived class MyObject only without any of the base classes?

Baumflaum
  • 749
  • 7
  • 20

1 Answers1

0

Using this code snippet from the Qt documentation, one can list the properties of the derived class only:

const QMetaObject* metaObject = myObj->metaObject();
QStringList properties;
for(int i = metaObject->propertyOffset(); i < metaObject->propertyCount(); ++i)
    properties << QString::fromLatin1(metaObject->property(i).name());

This should work with Qt 4, 5 and 6. Tested with Qt 4.8.

Baumflaum
  • 749
  • 7
  • 20