property / setProperty and iterating...
-
I have a lot of properties set using setProperty in my application. I can retrieve the properties calling property and I can see they are stored correctly. I want to create a generic loop to iterate through all the properties so I wrote:
const QMetaObject* cpobjMetaObject((QMetaObject*)metaObject()); for( int i=cpobjMetaObject->propertyOffset() ;i<cpobjMetaObject->propertyCount() ;i++ ) { QMetaProperty objProperty(cpobjMetaObject->property(i)); qDebug() << "HACK"; }The debug line is just there so I can set a breakpoint in the debugger in the loop, I have tested using debugger and can see that both propertyOffset and propertyCount both return 66.
This isn't correct, what am I missing?
-
I have a lot of properties set using setProperty in my application. I can retrieve the properties calling property and I can see they are stored correctly. I want to create a generic loop to iterate through all the properties so I wrote:
const QMetaObject* cpobjMetaObject((QMetaObject*)metaObject()); for( int i=cpobjMetaObject->propertyOffset() ;i<cpobjMetaObject->propertyCount() ;i++ ) { QMetaProperty objProperty(cpobjMetaObject->property(i)); qDebug() << "HACK"; }The debug line is just there so I can set a breakpoint in the debugger in the loop, I have tested using debugger and can see that both propertyOffset and propertyCount both return 66.
This isn't correct, what am I missing?
@SPlatten said in property / setProperty and iterating...:
This isn't correct, what am I missing?
You are mixing up
QMetaObjectproperties (which are static, created by MOC) andQObjectdynamic properties!
What you are looking for isQObject::dynamicPropertyNames() -
@SPlatten said in property / setProperty and iterating...:
This isn't correct, what am I missing?
You are mixing up
QMetaObjectproperties (which are static, created by MOC) andQObjectdynamic properties!
What you are looking for isQObject::dynamicPropertyNames()@KroMignon , thank you!