title: C++ Preprocessor and QT MOC
body: <p>I am attempting something (perhaps stupid).</p>
  
  <p>Have used some macroes to create "amounts" of functions in C++ domain;</p>
  
  <pre><code>#define THR_CONFIG_VALUE(path, value, type, name, defaultvalue) \
      type name() { return m_##name; } \
      void set##name(type data) { m_##name = data; }
  #include &lt;backend/config.i&gt;
  #undef THR_CONFIG_VALUE
  </code></pre>
  
  <p>Based upon following config.i file:</p>
  
  <pre><code>THR_CONFIG_VALUE("", "type", int, ThisType, 0)
  THR_CONFIG_VALUE("", "auto", bool, AutoVar1, false)
  THR_CONFIG_VALUE("", "auto", bool, AutoVar2, false)
  </code></pre>
  
  <p>That works fine, i get a number of getter setter functions, also generate member variables the same way (for the record).</p>
  
  <p>Now I start mixing up with QT stuff, trying to use the MOC to generate the Q_PROPERTIES:</p>
  
  <pre><code>#define THR_CONFIG_VALUE(path, value, type, name, defaultvalue) \
      Q_PROPERTY(type name READ name WRITE set##name NOTIFY indexChanged)
  #include &lt;backend/vessel/thruster/thruster_config.i&gt;
  #undef THR_CONFIG_VALUE
  </code></pre>
  
  <p>The MOC do not care for such attempts. This would have saved me typing 170 Q_PROPERTY lines and in the future several 100's more. </p>
  
  <p>Question 1: Why, preprocessor and MOC sequence?
  Question 2: Is there a "QT way" ?</p>
  
  <p>Thanks,</p>