Is there a way to assign arbitrary metadata to QObject properties?
-
I'm using QObject-derived classes and their properties to implement a data model. In order to introspectively discover characteristics of the properties of objects without needing to know what kind of object they are, I'd like to be able to associate metadata with certain properties.
I'm mainly interested in simply flagging certain properties for a certain characteristic. But it'd be great if I could associate a piece of metadata, such as a string or integer value, to a certain property as well.
So far, the only method I've found to do this is to use Q_CLASSINFO. I set its name to be something that indicates what characteristic it's flagging, and then the value is a comma-separated list of property names. This works, but it's a little clumsy since I have to resort to string parsing. Can anyone suggest a better way?
-
Hi,
Can you show an example of metadata annotation you would like to have ?
Does it need to be static ?
-
@SGaist said in Is there a way to assign arbitrary metadata to QObject properties?:
Hi,
Can you show an example of metadata annotation you would like to have ?
Does it need to be static ?
I might like to flag a property as "skip during serialization". Or "value is not case sensitive". Things like that.
An example of a metadata annotation that would include a value could be a "priority" integer value for certain properties.
Strictly speaking it doesn't need to be static for my purposes, but I'm not currently planning on changing these annotations or their values (if they have one) at runtime. It's all defined at compile time.
-
Then maybe something like the json based plugin metadata used by Qt and Qt Creator.