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. Property mapping using metaprogramming
Forum Updated to NodeBB v4.3 + New Features

Property mapping using metaprogramming

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.9k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Mercurial
    wrote on last edited by
    #1

    I wanted to serialize some of my objects as XML and came to an idea to map serializable properties somehow and give them an identifier(like a mapping name). Sure I could make a mapping file, but is there a in-code solution using meta programming ?

    Note that my question is about metaprogramming, not XML. XML serialization was just a spark that started the fire.

    Thanks in advance,

    Mercurial

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      In's not really a metaprogramming (int the C++ sense i.e. templates), but in each QObject derivative you can get a "QMetaObject":http://qt-project.org/doc/qt-5.0/qtcore/qmetaobject.html via metaObject() method.
      It contains information about properties, methods, enums, children etc.
      QMetaObject provides a serializable name for the properties.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mercurial
        wrote on last edited by
        #3

        But the property must be derived from QObject, right? What about primitives?

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          No, the property itself doesn't have to be QObject based. In fact it rarely is. Only the object that holds the property does.
          You can read more about Qt property system "here":http://qt-project.org/doc/qt-5.0/qtcore/properties.html

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mercurial
            wrote on last edited by
            #5

            Thank you very much.

            1 Reply Last reply
            0

            • Login

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