使用QMetaObject获取类的属性
const QMetaObject *metaobject = object->metaObject(); int count = metaobject->propertyCount(); for (int i = 0; i < count; ++i) { QMetaProperty metaproperty = metaobject->property(i); const char *name = metaproperty.name(); QVariant value = object->property(name); qDebug() << name << value; }