I am trying to use the Qt reflection for converting enum to QString.
Here is the part of code:
class ModelApple { Q_GADGET Q_ENUMS(AppleType)
How about:
QString convertEnumToQString(ModelApple::AppleType type) { const QMetaObject &mo = ModelApple::staticMetaObject; int index = mo.indexOfEnumerator("AppleType"); QMetaEnum metaEnum = mo.enumerator(index); return metaEnum.valueToKey(type); }
UPDATED: For Qt 5.5, see this answer