aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/doc/extras/QtCore.QEnum.rst
blob: cc565e9aaa9b46ac74d75251afb3d0bbf9547b67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
PySide6.QtCore.QEnum
====================

.. currentmodule:: PySide6.QtCore
.. py:decorator:: QEnum

    This class decorator is equivalent to the `Q_ENUM` macro from Qt. The decorator
    is used to register a Python Enum derived class to the meta-object system,
    which is available via `QObject.staticMetaObject`. The enumerator must
    be in a :class:`QObject` derived class to be registered.

    Example
    -------

    ::

        from enum import Enum, auto

        from PySide6.QtCore import QEnum, QObject

        class Demo(QObject):

            @QEnum
            class Orientation(Enum):
                North, East, South, West = range(4)

    See :deco:`QFlag` for registering Python Flag derived classes.

    Meanwhile all enums and flags have been converted to Python Enums
    (default since ``PySide 6.4``), see the :ref:`NewEnumSystem` section.