内容表

上一话题

QMetaClassInfo

下一话题

QMetaMethod

QMetaEnum

QMetaEnum class provides meta-data about an enumerator. 更多

Inheritance diagram of PySide2.QtCore.QMetaEnum

概要

函数

详细描述

使用 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() ,和 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.

class QMetaEnum

QMetaEnum(QMetaEnum)

参数

QMetaEnum QMetaEnum

PySide2.QtCore.QMetaEnum. enumName ( )
返回类型

str

返回标志的枚举名称 (在作用域外)。

例如, AlignmentFlag flag has AlignmentFlag as the enum name, but Alignment as 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 ( )
返回类型

bool

返回 true if this enumerator is used as a flag; otherwise returns false.

When used as flags, enumerators can be combined using the OR operator.

PySide2.QtCore.QMetaEnum. isScoped ( )
返回类型

bool

返回 true if this enumerator is declared as a C++11 enum class; otherwise returns false.

PySide2.QtCore.QMetaEnum. isValid ( )
返回类型

bool

返回 true if this enum is valid (has a name); otherwise returns false.

另请参阅

name()

PySide2.QtCore.QMetaEnum. key ( index )
参数

index int

返回类型

str

Returns the key with the given index ,或 None if no such key exists.

PySide2.QtCore.QMetaEnum. keyCount ( )
返回类型

int

返回键数。

另请参阅

key()

PySide2.QtCore.QMetaEnum. keyToValue ( key )
参数

key – str

返回类型

PyTuple

Returns the integer value of the given enumeration key , or -1 if key is not defined.

key is not defined, *``ok`` is set to false; otherwise *``ok`` is set to true.

For flag types, use keysToValue() .

PySide2.QtCore.QMetaEnum. keysToValue ( keys )
参数

keys – str

返回类型

PyTuple

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.

keys is not defined, *``ok`` is set to false; otherwise *``ok`` is set to true.

PySide2.QtCore.QMetaEnum. name ( )
返回类型

str

Returns the name of the type (without the scope).

例如, Key enumeration has Key as 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.

PySide2.QtCore.QMetaEnum. scope ( )
返回类型

str

Returns the scope this enumerator was declared in.

例如, AlignmentFlag enumeration has Qt as the scope and AlignmentFlag as the name.

另请参阅

name()

PySide2.QtCore.QMetaEnum. value ( index )
参数

index int

返回类型

int

Returns the value with the given index ; or returns -1 if there is no such value.

PySide2.QtCore.QMetaEnum. valueToKey ( value )
参数

value int

返回类型

str

Returns the string that is used as the name of the given enumeration value ,或 None if value is not defined.

For flag types, use valueToKeys() .

PySide2.QtCore.QMetaEnum. valueToKeys ( value )
参数

value int

返回类型

QByteArray

Returns a byte array of ‘|’-separated keys that represents the given value .