QMetaEnum¶

Synopsis¶
Functions¶
def
enumName()def
isFlag()def
isScoped()def
isValid()def
key(index)def
keyCount()def
keyToValue(key)def
keysToValue(keys)def
name()def
scope()def
value(index)def
valueToKey(value)def
valueToKeys(value)
Detailed Description¶
Use
name()for the enumerator’s name. The enumerator’s keys (names of each enumerated item) are returned bykey(); usekeyCount()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(), andvalueToKeys()allow conversion between the integer representation of an enumeration or set value and its literal representation. Thescope()function returns the class scope this enumerator was declared in.See also
- class PySide2.QtCore.QMetaEnum¶
PySide2.QtCore.QMetaEnum(QMetaEnum)
- Parameters:
QMetaEnum –
PySide2.QtCore.QMetaEnum
- PySide2.QtCore.QMetaEnum.enumName()¶
- Return type:
str
Returns the enum name of the flag (without the scope).
For example, the
AlignmentFlagflag hasAlignmentFlagas the enum name, butAlignmentas as the type name. Non flag enums has the same type and enum names.Enum names have the same scope as the type name.
- PySide2.QtCore.QMetaEnum.isFlag()¶
- Return type:
bool
Returns
trueif this enumerator is used as a flag; otherwise returns false.When used as flags, enumerators can be combined using the OR operator.
See also
- PySide2.QtCore.QMetaEnum.isScoped()¶
- Return type:
bool
Returns
trueif this enumerator is declared as a C++11 enum class; otherwise returns false.
- PySide2.QtCore.QMetaEnum.isValid()¶
- Return type:
bool
Returns
trueif this enum is valid (has a name); otherwise returns false.See also
- PySide2.QtCore.QMetaEnum.key(index)¶
- Parameters:
index – int
- Return type:
str
Returns the key with the given
index, orNoneif no such key exists.See also
- PySide2.QtCore.QMetaEnum.keyToValue(key)¶
- Parameters:
key – str
- Return type:
PyTuple
Returns the integer value of the given enumeration
key, or -1 ifkeyis not defined.If
keyis not defined, *``ok`` is set to false; otherwise *``ok`` is set to true.For flag types, use
keysToValue().See also
- PySide2.QtCore.QMetaEnum.keysToValue(keys)¶
- Parameters:
keys – str
- Return type:
PyTuple
Returns the value derived from combining together the values of the
keysusing the OR operator, or -1 ifkeysis not defined. Note that the strings inkeysmust be ‘|’-separated.If
keysis not defined, *``ok`` is set to false; otherwise *``ok`` is set to true.See also
- PySide2.QtCore.QMetaEnum.name()¶
- Return type:
str
Returns the name of the type (without the scope).
For example, the
Keyenumeration hasKeyas the type name and Qt as the scope.For flags this returns the name of the flag type, not the name of the enum type.
See also
- PySide2.QtCore.QMetaEnum.scope()¶
- Return type:
str
Returns the scope this enumerator was declared in.
For example, the
AlignmentFlagenumeration hasQtas the scope andAlignmentFlagas the name.See also
- PySide2.QtCore.QMetaEnum.value(index)¶
- Parameters:
index – int
- Return type:
int
Returns the value with the given
index; or returns -1 if there is no such value.See also
- PySide2.QtCore.QMetaEnum.valueToKey(value)¶
- Parameters:
value – int
- Return type:
str
Returns the string that is used as the name of the given enumeration
value, orNoneifvalueis not defined.For flag types, use
valueToKeys().See also
- PySide2.QtCore.QMetaEnum.valueToKeys(value)¶
- Parameters:
value – int
- Return type:
Returns a byte array of ‘|’-separated keys that represents the given
value.See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.