Skip to content

StateMachine

Qt Base Class: QStateMachine

Signature: QStateMachine(self, childMode: PySide6.QtStateMachine.QState.ChildMode, parent: Optional[PySide6.QtCore.QObject] = None) -> None QStateMachine(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None

Base classes

Name Children Inherits
StateMixin
prettyqt.statemachine.state
QStateMachine
PySide6.QtStateMachine
QStateMachine(self, childMode: PySide6.QtStateMachine.QState.ChildMode, parent: Optional[PySide6.QtCore.QObject] \= None) -> None

⋔ Inheritance diagram

graph TD
  1473374547232["statemachine.StateMachine"]
  1473374539424["statemachine.StateMixin"]
  1473374532592["statemachine.AbstractStateMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473374525760["QtStateMachine.QStateMachine"]
  1473374520880["QtStateMachine.QState"]
  1473374523808["QtStateMachine.QAbstractState"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473374539424 --> 1473374547232
  1473374532592 --> 1473374539424
  1473299815024 --> 1473374532592
  140713234304496 --> 1473299815024
  1473374525760 --> 1473374547232
  1473374520880 --> 1473374525760
  1473374523808 --> 1473374520880
  1473288842240 --> 1473374523808
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: StateMixin, QStateMachine

Source code in prettyqt\statemachine\statemachine.py
class StateMachine(statemachine.state.StateMixin, statemachine.QStateMachine):
    def __add__(self, other: statemachine.QAbstractState) -> StateMachine:
        self.addState(other)
        return self

    def get_error(self) -> ErrorStr:
        return ERROR.inverse[self.error()]

    def post_event(
        self,
        event: QtCore.QEvent,
        priority: PriorityStr | statemachine.QStateMachine.EventPriority = "normal",
    ):
        self.postEvent(event, PRIORITY.get_enum_value(priority))

    def set_global_restore_policy(
        self,
        policy: statemachine.state.RestorePolicyStr | statemachine.State.RestorePolicy,
    ):
        """Set restore policy to use.

        Args:
            policy: restore policy to use
        """
        self.setGlobalRestorePolicy(
            statemachine.state.RESTORE_POLICY.get_enum_value(policy)
        )

    def get_global_restore_policy(self) -> statemachine.state.RestorePolicyStr:
        """Return current restore policy.

        Returns:
            restore policy
        """
        return statemachine.state.RESTORE_POLICY.inverse[self.globalRestorePolicy()]

get_global_restore_policy() -> statemachine.state.RestorePolicyStr

Return current restore policy.

Source code in prettyqt\statemachine\statemachine.py
def get_global_restore_policy(self) -> statemachine.state.RestorePolicyStr:
    """Return current restore policy.

    Returns:
        restore policy
    """
    return statemachine.state.RESTORE_POLICY.inverse[self.globalRestorePolicy()]

set_global_restore_policy(policy: statemachine.state.RestorePolicyStr | statemachine.State.RestorePolicy)

Set restore policy to use.

Parameters:

Name Type Description Default
policy RestorePolicyStr | RestorePolicy

restore policy to use

required
Source code in prettyqt\statemachine\statemachine.py
def set_global_restore_policy(
    self,
    policy: statemachine.state.RestorePolicyStr | statemachine.State.RestorePolicy,
):
    """Set restore policy to use.

    Args:
        policy: restore policy to use
    """
    self.setGlobalRestorePolicy(
        statemachine.state.RESTORE_POLICY.get_enum_value(policy)
    )

⌗ Property table

Qt Property Type Doc
objectName QString
active bool
initialState QAbstractState
errorState QAbstractState
childMode QState::ChildMode
errorString QString
globalRestorePolicy QState::RestorePolicy
running bool
animated bool