CopperSpice API
1.9.2
|
Provides meta data about an enumerator. More...
Public Methods | |
bool | isFlag () const |
bool | isValid () const |
const QString & | key (int index) const |
int | keyCount () const |
int | keysToValue (const QString &keys) const |
int | keyToValue (const QString &key) const |
const QString & | name () const |
const QString & | scope () const |
int | value (int index) const |
const QString & | valueToKey (int value) const |
QString | valueToKeys (int value) const |
The QMetaEnum class provides meta data about an enum or enumerator. The name() method is used to return the name of the enum. The scope() method returns the class scope this enumerator was declared in. Calling keyCount() will return the number of elements in the enum.
The enumerator's keys (names of each enumerated item) are returned by calling key() and passing an index of which ennum value to return. The first enum value is zero.
The isFlag() method returns whether the enumerator is meant to be used as a flag, meaning that its values can be combined using the OR operator.
The conversion functions keyToValue(), valueToKey(), keysToValue(), and valueToKeys() allow conversions between the integer representation of an enumeration or set value and the literal representation.
bool QMetaEnum::isFlag | ( | ) | const |
Returns true if this enumerator is used as a flag, otherwise returns false. When used as flags, values can be combined using the OR operator.
bool QMetaEnum::isValid | ( | ) | const |
Returns true if this enum is valid and has a name, otherwise returns false.
const QString & QMetaEnum::key | ( | int | index | ) | const |
Returns the key with the given index or an empty string if no key exists.
int QMetaEnum::keyCount | ( | ) | const |
Returns the number of keys in the current QMetaEnum.
Qt::Orientation is an enum located in the class named Qt. The following example shows how to retrieve the QMetaEnum and then print the names of each element in the enum.
int QMetaEnum::keysToValue | ( | const QString & | keys | ) | const |
Returns the value derived from combining together the values of the keys using the OR operator, or -1 if keys is not defined. The names in the key must be separated by a '|' character.
int QMetaEnum::keyToValue | ( | const QString & | key | ) | const |
Returns the integer value of the given enumeration key, or -1 if key is not defined. For flag types, use keysToValue().
Qt::Orientation is an enum located in the class named Qt. The following example shows how to retrieve the QMetaEnum and then query the value for one of the elements.
const QString & QMetaEnum::name | ( | ) | const |
Returns the name of the enumerator (without the scope). For example, the Qt::Orientation enumeration has a name of Orientation.
const QString & QMetaEnum::scope | ( | ) | const |
Returns the scope this enumerator was declared in. For example the Qt::Orientation enumeration has a scope of Qt since it is located in the class Qt.
int QMetaEnum::value | ( | int | index | ) | const |
Returns the value with the given index or returns -1 if there is no value.
const QString & QMetaEnum::valueToKey | ( | int | value | ) | const |
Returns the string used as the name of the given enumeration value or an empty string if value is not defined. For flag types use valueToKeys().
QString QMetaEnum::valueToKeys | ( | int | value | ) | const |
Returns a string of '|' separated keys which represent the given values.