PDA

View Full Version : Counting and looping properties



stefan
25th January 2011, 10:41
hi,
i have a class with properties and i want to make automatic XML saving of all properties.
can i loop trough all properties?
something like this

for(quint i=0;i<propertiesCount();i++)
{
saveToXml(properties[i]);
}

Maybe someone have a solution that i can apply?
or there is another way, that is commonly used?

Thank you

MarekR22
25th January 2011, 13:32
QObject::metaObject

QMetaObject::propertyOffset

QMetaProperty

QMetaProperty::isStored

stefan
25th January 2011, 13:38
ill try this:

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