Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
\inmodule QtCore More...
#include <qmetaobject.h>
Public Member Functions | |
constexpr | QMetaEnum () |
const char * | name () const |
Returns the name of the type (without the scope). | |
const char * | enumName () const |
Returns the enum name of the flag (without the scope). | |
QMetaType | metaType () const |
Returns the meta type of the enum. | |
bool | isFlag () const |
Returns true if this enumerator is used as a flag; otherwise returns false. | |
bool | isScoped () const |
int | keyCount () const |
Returns the number of keys. | |
const char * | key (int index) const |
Returns the key with the given index, or \nullptr if no such key exists. | |
int | value (int index) const |
Returns the value with the given index; or returns -1 if there is no such value. | |
const char * | scope () const |
Returns the scope this enumerator was declared in. | |
int | keyToValue (const char *key, bool *ok=nullptr) const |
Returns the integer value of the given enumeration key, or -1 if key is not defined. | |
const char * | valueToKey (int value) const |
Returns the string that is used as the name of the given enumeration value, or \nullptr if value is not defined. | |
int | keysToValue (const char *keys, bool *ok=nullptr) const |
Returns the value derived from combining together the values of the keys using the OR operator, or -1 if keys is not defined. | |
QByteArray | valueToKeys (int value) const |
Returns a byte array of '|'-separated keys that represents the given value. | |
const QMetaObject * | enclosingMetaObject () const |
bool | isValid () const |
Returns true if this enum is valid (has a name); otherwise returns false. | |
Static Public Member Functions | |
template<typename T > | |
static QMetaEnum | fromType () |
Friends | |
struct | QMetaObject |
struct | QMetaObjectPrivate |
\inmodule QtCore
The QMetaEnum class provides meta-data about an enumerator.
Use name() for the enumerator's name. The enumerator's keys (names of each enumerated item) are returned by key(); use keyCount() to find the number of keys. isFlag() 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 conversion between the integer representation of an enumeration or set value and its literal representation. The scope() function returns the class scope this enumerator was declared in.
Definition at line 263 of file qmetaobject.h.
|
inlineconstexpr |
Definition at line 266 of file qmetaobject.h.
|
inline |
Definition at line 286 of file qmetaobject.h.
Referenced by isScopeMatch().
const char * QMetaEnum::enumName | ( | ) | const |
Returns the enum name of the flag (without the scope).
For example, the Qt::AlignmentFlag flag has AlignmentFlag
as the enum name, but Alignment
as the type name. Non flag enums has the same type and enum names.
Enum names have the same scope as the type name.
Definition at line 3078 of file qmetaobject.cpp.
References rawStringData().
Referenced by QMetaObjectBuilder::addEnumerator(), isScopeMatch(), qt_QMetaEnum_debugOperator(), and qt_QMetaEnum_flagDebugOperator().
|
inlinestatic |
Returns the QMetaEnum corresponding to the type in the template parameter. The enum needs to be declared with Q_ENUM.
Definition at line 291 of file qmetaobject.h.
References metaObject().
bool QMetaEnum::isFlag | ( | ) | const |
Returns true
if this enumerator is used as a flag; otherwise returns false.
When used as flags, enumerators can be combined using the OR operator.
Definition at line 3161 of file qmetaobject.cpp.
References EnumIsFlag.
Referenced by QMetaObjectBuilder::addEnumerator().
bool QMetaEnum::isScoped | ( | ) | const |
Returns true
if this enumerator is declared as a C++11 enum class; otherwise returns false.
Definition at line 3174 of file qmetaobject.cpp.
References EnumIsScoped.
Referenced by QMetaObjectBuilder::addEnumerator(), qt_QMetaEnum_debugOperator(), and qt_QMetaEnum_flagDebugOperator().
|
inline |
Returns true
if this enum is valid (has a name); otherwise returns false.
Definition at line 288 of file qmetaobject.h.
const char * QMetaEnum::key | ( | int | index | ) | const |
Returns the key with the given index, or \nullptr if no such key exists.
Definition at line 3128 of file qmetaobject.cpp.
References QMetaObject::d, and rawStringData().
Referenced by QMetaObjectBuilder::addEnumerator().
int QMetaEnum::keyCount | ( | ) | const |
Returns the number of keys.
Definition at line 3116 of file qmetaobject.cpp.
Referenced by QMetaObjectBuilder::addEnumerator().
int QMetaEnum::keysToValue | ( | const char * | keys, |
bool * | ok = nullptr ) const |
Returns the value derived from combining together the values of the keys using the OR operator, or -1 if keys is not defined.
Note that the strings in keys must be '|'-separated.
If keys is not defined, *{ok} is set to false; otherwise {ok} is set to true.
Definition at line 3324 of file qmetaobject.cpp.
References QMetaObject::d, i, isScopeMatch(), keys, list, ok, parse_scope(), parseEnumFlags(), and stringDataView().
Referenced by QMetaProperty::write(), and QQmlPropertyPrivate::writeEnumProperty().
int QMetaEnum::keyToValue | ( | const char * | key, |
bool * | ok = nullptr ) const |
Returns the integer value of the given enumeration key, or -1 if key is not defined.
If key is not defined, *{ok} is set to false; otherwise {ok} is set to true.
For flag types, use keysToValue().
Definition at line 3232 of file qmetaobject.cpp.
References QMetaObject::d, i, isScopeMatch(), ok, parse_scope(), and stringDataView().
Referenced by toEnumValue(), toEnumValue(), QMetaProperty::write(), and QQmlPropertyPrivate::writeEnumProperty().
QMetaType QMetaEnum::metaType | ( | ) | const |
Returns the meta type of the enum.
If the QMetaObject that this enum is part of was generated with Qt 6.5 or earlier, this will be an invalid meta type.
Definition at line 3097 of file qmetaobject.cpp.
References QMetaObject::d, and priv().
Referenced by QMetaObjectBuilder::addEnumerator(), and QMetaProperty::typeName().
const char * QMetaEnum::name | ( | ) | const |
Returns the name of the type (without the scope).
For example, the Qt::Key enumeration has Key
as the type name and \l Qt as the scope.
For flags this returns the name of the flag type, not the name of the enum type.
Definition at line 3059 of file qmetaobject.cpp.
References rawStringData().
Referenced by QMetaObjectBuilder::addEnumerator(), and QQmlMetaType::clone().
const char * QMetaEnum::scope | ( | ) | const |
Returns the scope this enumerator was declared in.
For example, the Qt::AlignmentFlag enumeration has Qt
as the scope and AlignmentFlag
as the name.
Definition at line 3189 of file qmetaobject.cpp.
References QMetaObject::className().
Referenced by qt_QMetaEnum_debugOperator(), and qt_QMetaEnum_flagDebugOperator().
int QMetaEnum::value | ( | int | index | ) | const |
Returns the value with the given index; or returns -1 if there is no such value.
Definition at line 3143 of file qmetaobject.cpp.
References QMetaObject::d.
Referenced by QMetaObjectBuilder::addEnumerator().
const char * QMetaEnum::valueToKey | ( | int | value | ) | const |
Returns the string that is used as the name of the given enumeration value, or \nullptr if value is not defined.
For flag types, use valueToKeys().
Definition at line 3259 of file qmetaobject.cpp.
References QMetaObject::d, i, and rawStringData().
Referenced by QQnxButtonEventNotifier::QQnxButtonEventNotifier(), errorToString(), QtDebugUtils::formatQEnum(), QXcbWindow::handleXIMouseEvent(), qt_QMetaEnum_debugOperator(), QTest::Internal::toString(), and QTest::Internal::toString().
QByteArray QMetaEnum::valueToKeys | ( | int | value | ) | const |
Returns a byte array of '|'-separated keys that represents the given value.
Definition at line 3386 of file qmetaobject.cpp.
References QMetaObject::d, i, keys, and stringDataView().
Referenced by QtDebugUtils::formatQFlags(), qt_QMetaEnum_flagDebugOperator(), QTest::Internal::toString(), and QTest::Internal::toString().
|
friend |
Definition at line 318 of file qmetaobject.h.
|
friend |
Definition at line 319 of file qmetaobject.h.