Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is there a way to assign arbitrary metadata to QObject properties?

Is there a way to assign arbitrary metadata to QObject properties?

Scheduled Pinned Locked Moved Unsolved General and Desktop
propertiesqobjectmetadata
4 Posts 2 Posters 597 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    Guy Gizmo
    wrote on 8 Jun 2021, 16:26 last edited by
    #1

    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?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 8 Jun 2021, 18:28 last edited by
      #2

      Hi,

      Can you show an example of metadata annotation you would like to have ?

      Does it need to be static ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply 8 Jun 2021, 19:20
      0
      • S SGaist
        8 Jun 2021, 18:28

        Hi,

        Can you show an example of metadata annotation you would like to have ?

        Does it need to be static ?

        G Offline
        G Offline
        Guy Gizmo
        wrote on 8 Jun 2021, 19:20 last edited by
        #3

        @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.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 8 Jun 2021, 19:55 last edited by
          #4

          Then maybe something like the json based plugin metadata used by Qt and Qt Creator.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          2/4

          8 Jun 2021, 18:28

          • Login

          • Login or register to search.
          2 out of 4
          • First post
            2/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved