Table Of Contents

Previous topic

QStateMachine.SignalEvent

Next topic

QFinalState

QHistoryState

Note

This class was introduced in Qt 4.6

Synopsis

Functions

Detailed Description

The PySide.QtCore.QHistoryState class provides a means of returning to a previously active substate.

A history state is a pseudo-state that represents the child state that the parent state was in the last time the parent state was exited. A transition with a history state as its target is in fact a transition to one of the other child states of the parent state. PySide.QtCore.QHistoryState is part of The State Machine Framework .

Use the PySide.QtCore.QHistoryState.setDefaultState() function to set the state that should be entered if the parent state has never been entered. Example:

machine = QStateMachine()

s1 = new QState()
s11 = new QState(s1)
s12 = new QState(s1)

s1h = QHistoryState(s1)
s1h.setDefaultState(s11)

machine.addState(s1)

s2 = QState()
machine.addState(s2)

button = QPushButton()
# Clicking the button will cause the state machine to enter the child state
# that s1 was in the last time s1 was exited, or the history state's default
# state if s1 has never been entered.
s1.addTransition(button.clicked, s1h)

By default a history state is shallow, meaning that it won’t remember nested states. This can be configured through the PySide.QtCore.QHistoryState.historyType() property.

class PySide.QtCore.QHistoryState(type[, parent=None])
class PySide.QtCore.QHistoryState([parent=None])
Parameters:

Constructs a new history state of the given type , with the given parent state.

Constructs a new shallow history state with the given parent state.

PySide.QtCore.QHistoryState.HistoryType

This enum specifies the type of history that a PySide.QtCore.QHistoryState records.

Constant Description
QHistoryState.ShallowHistory Only the immediate child states of the parent state are recorded. In this case a transition with the history state as its target will end up in the immediate child state that the parent was in the last time it was exited. This is the default.
QHistoryState.DeepHistory Nested states are recorded. In this case a transition with the history state as its target will end up in the most deeply nested descendant state the parent was in the last time it was exited.
PySide.QtCore.QHistoryState.defaultState()
Return type:PySide.QtCore.QAbstractState

This property holds the default state of this history state.

PySide.QtCore.QHistoryState.historyType()
Return type:PySide.QtCore.QHistoryState.HistoryType

This property holds the type of history that this history state records.

The default value of this property is QHistoryState.ShallowHistory .

PySide.QtCore.QHistoryState.setDefaultState(state)
Parameters:statePySide.QtCore.QAbstractState

This property holds the default state of this history state.

PySide.QtCore.QHistoryState.setHistoryType(type)
Parameters:typePySide.QtCore.QHistoryState.HistoryType

This property holds the type of history that this history state records.

The default value of this property is QHistoryState.ShallowHistory .