title: Q_ENUMS are "undefined" in QML?
body: <p>Enums are not working out for me. </p>
  
  <ul>
  <li>I have registered them with <code>Q_ENUMS()</code></li>
  <li>I did not forget the <code>Q_OBJECT</code> macro</li>
  <li>the type is registered using <code>qmlRegisterType()</code></li>
  <li>the module is imported in QML</li>
  </ul>
  
  <p>In short, everything is "by-the-book" but for some reason I continue getting <code>undefined</code> for each and every enum in QML. Am I missing something?</p>
  
  <pre><code>class UI : public QQuickItem {
      Q_OBJECT
      Q_ENUMS(ObjectType)
  public:
  enum ObjectType {
          _Root = 0,
          _Block
      };
  ...
  };
  </code></pre>
  
  <p>...</p>
  
  <pre><code>qmlRegisterType&lt;UI&gt;("Nodes", 1, 0, "UI");
  </code></pre>
  
  <p>...</p>
  
  <pre><code>import Nodes 1.0
  ...
  console.log(UI._Root) // undefined
  </code></pre>
  
  <p>EDIT: Also note that the registered enums are indeed available to use for the metasystem, for some reason they do not work in QML.</p>
  
  <p>UPDATE: I just found this bug: <a href="https://bugreports.qt.io/browse/QTBUG-33248" rel="nofollow noreferrer">https://bugreports.qt.io/browse/QTBUG-33248</a>
  But unlike that bug my root component is a bare <code>UI</code> not a custom element with <code>UI</code> as its root.</p>
  
  <p>Turns out that it is actually possible to use enum values form QML in <code>console.log()</code>, the following code is actually working.</p>
  
  <pre><code>class A : public QObject {
      Q_OBJECT
      Q_ENUMS(EA)
  public:
      enum EA {
          EA_NULL = 0,
          EA_ONE
      };
  };
  
  class B : public A {
      Q_OBJECT
      Q_ENUMS(EB)
  public:
      enum EB {
          EA_TWO = 2,
          EA_THREE
      };
  };
  
  #include "main.moc"
  
  int main(int argc, char *argv[])
  {
      QGuiApplication app(argc, argv);
      qmlRegisterType&lt;A&gt;("test", 1, 0, "A");
      qmlRegisterType&lt;B&gt;("test", 1, 0, "B");
  
      QtQuick2ApplicationViewer viewer;
      viewer.setMainQmlFile(QStringLiteral("qml/enums/main.qml"));
      viewer.showExpanded();
  
      return app.exec();
  }
  </code></pre>
  
  <p>and...</p>
  
  <pre><code>Component.onCompleted: {
          console.log(A.EA_NULL)
          console.log(A.EA_ONE)
  
          console.log(B.EA_NULL)
          console.log(B.EA_ONE)
          console.log(B.EA_TWO)
          console.log(B.EA_THREE)
      }
  </code></pre>
  
  <p>Output is:</p>
  
  <pre><code>0
  1
  0
  1
  2
  3
  </code></pre>
  
  <p>So I guess there is another problem besides "you are not using it correctly"... It might have to do with the bug I mentioned above, and the fact that when I instantiate the <code>UI</code> element, I actually instantiate a QML component which is a tree of objects with the <code>UI</code> as the root. While this doesn't prove to be any problem for working with pointers from C++ with the full QML objects, it does seem to mess enums for some reason.</p>