title: Using c++ enum in QML as string
body: <p>What I would like to do is use the below enum in c++:</p>
  
  <pre><code>class MyClass : public QQuickItem {
      Q_OBJECT
      Q_PROPERTY(MyEnum enumValue READ getEnumValue)
  
  public:
      enum MyEnum{
          MyEnumElement = 0
      };
      Q_ENUM(MyEnum)
  
  slots:
      MyEnum getEnumValue(){
          return enumValue;
      }
  
  private: 
      MyEnum enumValue = MyEnumElement;
  };
  </code></pre>
  
  <p>In such a way in QML:</p>
  
  <pre><code>MyClass {
      id: myClass
  }
  
  Text {
      text: "enumValue is: " + myClass.enumValue
  }
  </code></pre>
  
  <p>That would result in <code>enumValue is MyEnumElement</code> instead of <code>enumValue is 0</code> which is the case now. The solution I have now is the following, however inelegant:</p>
  
  <pre><code>class MyClass : public QQuickItem {
      Q_OBJECT
      Q_PROPERTY(MyEnum enumValue READ getEnumValue)
  
  public:
      enum MyEnum{
          MyEnumElement = 0
      };
      Q_ENUM(MyEnum)
      QMetaEnum MyEnum_MetaEnum = QMetaEnum::fromType&lt;MyEnum&gt;();
      Q_INVOKABLE QString getEnumString(MyEnum enumVal){
          return MyEnum_MetaEnum.valueToKey(enumVal);
      }
  
  slots:
      MyEnum getEnumValue(){
          return enumValue;
      }
  
  private: 
      MyEnum enumValue = MyEnumElement;
  };
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>MyClass {
      id: myClass
  }
  
  Text {
      text: "enumValue is: " + myClass.getEnumString(myClass.enumValue)
  }
  </code></pre>
  
  <p>Is there a better way to do this?</p>