Properties are not QObjects and don't have addresses. I think your whole concept is flawed because of a wrong assumption. If you'd like to get an address to a value of a property, it still wouldn't have worked as QVariant (which stores the value) is implicitly shared and thus the place in memory holding the value may vary in time (and you'd get a stale pointer). If you want to have a property which is QObject then that's another flaw as QVariant values are mutable and QObjects are not. You should only store a pointer to a QObject within a property.
Q_PROPERTY(int val READ ... WRITE ...);
// ...
};
Q_PROPERTY(QObject* abc READ ...
WRITE ...
);
// ...
};
// ...
ABC abc;
PropVal *prop = qobject_cast<PropVal*>(qvariant_cast<QObject*>(abc.property("abc")));
if(prop) {
int val = prop->property("val").toInt();
}
class PropVal : public QObject {
Q_PROPERTY(int val READ ... WRITE ...);
// ...
};
class ABC : public QObject {
Q_PROPERTY(QObject* abc READ ... WRITE ...);
// ...
};
// ...
ABC abc;
PropVal *prop = qobject_cast<PropVal*>(qvariant_cast<QObject*>(abc.property("abc")));
if(prop) {
int val = prop->property("val").toInt();
}
To copy to clipboard, switch view to plain text mode
Bookmarks