One more example:
#include <QCoreApplication> #include <iostream> #include <QMetaObject> #include "example.h" #include <QDebug> #include <QMetaProperty> #include <QPointer> void gadgetExplorer(void *ptr, const char* s) { //Receives Player and access its meta-object int typeId = QMetaType::type(s); const QMetaObject *mo = QMetaType::metaObjectForType(typeId); qInfo() << "Q_GADGET: " << mo->className(); QMetaProperty mp; for(int i = 1; i < mo->propertyCount(); i++) { mp = mo->property(i); qInfo() << "Q_PROPERTY: " << mp.typeName() << "Value: " << mp.readOnGadget(ptr); if(int(mp.type()) == 1024) gadgetExplorer(ptr, mp.typeName()); } } int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); qRegisterMetaType<Player>(); qRegisterMetaType<P2D>(); qRegisterMetaType<P2D*>(); Player p1; p1.setSpeed(30); p1.p2d = new P2D(); p1.p2d->setX(10.0); p1.p2d->setY(25.0); gadgetExplorer(&p1, "Player"); return a.exec(); }gadgetExplorer() works fine for the first Q_GADGET, but for the second one the read property doesn't work. Is it possible to access the second's Q_GADGET pointer?