|  | Home · All Classes · Modules

# QHistoryState Class Reference
[QtCore module]

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

Inherits QAbstractState.

### Types

- enum HistoryType { ShallowHistory, DeepHistory }

### Methods

- __init__ (self, QState parent = None)
- __init__ (self, HistoryType, QState parent = None)
- QAbstractState defaultState (self)
- bool event (self, QEvent)
- HistoryType historyType (self)
- onEntry (self, QEvent)
- onExit (self, QEvent)
- setDefaultState (self, QAbstractState)
- setHistoryType (self, HistoryType)

## Detailed Description

The 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. QHistoryState is part of The State Machine Framework.

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

     QStateMachine machine;

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

     QHistoryState *s1h = new QHistoryState(s1);
     s1h->setDefaultState(s11);

     machine.addState(s1);

     QState *s2 = new QState();
     machine.addState(s2);

     QPushButton *button = new 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, SIGNAL(clicked()), s1h);

By default a history state is shallow, meaning that it won't remember nested states. This can be configured through the historyType property.

## Type Documentation

### QHistoryState.HistoryType

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

Constant | Value | Description
--- | --- | ---
`QHistoryState.ShallowHistory` | `0` | 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` | `1` | 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.

## Method Documentation

### QHistoryState.__init__ (self, QState parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

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

### QHistoryState.__init__ (self, HistoryType, QState parent = None)

The parent argument, if not None, causes self to be owned by Qt instead of PyQt.

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

### QAbstractState QHistoryState.defaultState (self)

### bool QHistoryState.event (self, QEvent)

Reimplemented from QObject.event().

### HistoryType QHistoryState.historyType (self)

### QHistoryState.onEntry (self, QEvent)

Reimplemented from QAbstractState.onEntry().

### QHistoryState.onExit (self, QEvent)

Reimplemented from QAbstractState.onExit().

### QHistoryState.setDefaultState (self, QAbstractState)

### QHistoryState.setHistoryType (self, HistoryType)