QMetaEnum
QMetaEnum is a class in the QtCore module that provides runtime meta-information about a single enumeration type declared in a QObject-derived class or within a namespace. It enables introspection of the enum, including access to its enumerators, and allows conversion between numeric values and their string representations. This supports tasks such as debugging, serialization, and scripting where human-readable forms of enum values are desirable.
A QMetaEnum is obtained from a class’s meta-object, typically by calling the enumerator(index) function on a
- Map a value to its string key via valueToKey(int value).
- Map a string key to its numeric value via keyToValue(const char* key).
- Enumerate the available keys with keyCount() and by querying key(i) and value(i) for each index i.
- Determine the enum’s type name or scope, and check if the enum is intended as a set
Registering with the meta-object system is required for QMetaEnum to be available at runtime. In modern Qt
QMetaEnum is often used to convert between user-facing text and internal values, implement dynamic property editors,
---