EDITED: shorter example
-------------------------------
I know it is possible to dynamically add properties to QObject derived classes.
Suppose I have a second class "two", with a similar property (having the same data type).Qt Code:
To copy to clipboard, switch view to plain text mode
But I was wondering how to connect both properties using signals and slots?
Should I connect the QObject::setProperty()method? I fear that this would probably mean that setting any property on the first class, would automatically create the same property on the second class, which is clearly not the intention. I only want to ensure that if I connect two properties, setting the first will set the second one automatically.
I will first try to do this in one direction and worry about recursion later on.
Edited:
I created a wrapper method as a slot, "setValue" and a signal "valueChanged", which works, but as a result, if I connect two classes, all properties with the same name get connected. I only want to allow specific connections.
What I would like to avoid is creating a list of mapped properties (e.g. listener pattern) since I fear that I would create something that resembles the signal and slot mechanism, which is clearly a waste of efforts. I would rather use what is already implemented in Qt.
I read about "QDynamicPropertyChangeEvent". Is that an approach to it?
Bookmarks