Consider these classes:
Class A : public QObject {
...
Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
virtual int value() { return m_value; }
void setValue(int v) { m_value = v; Q_EMIT valueChanged();}
...
};
Class B : public A {
...
int value() { return m_value * 2; }
...
};
When property value is accessed, the Class A method is called directly instead of Class B's.
So far, to workaround this apparent limitation I've replicated the property code and connected the signals from each class.
Is this the best solution?
Does anyone see potential problems (due to the properties having the same name)?
From the Qt documentation:
The READ, WRITE, and RESET functions can be inherited. They can also be virtual. When they are inherited in classes where multiple inheritance is used, they must come from the first inherited class.
Just make the accessors virtual, and they will be invoked from the vtable, so you will get the right function for every different subtype.