• PySide 模块
  • PySide.QtCore
  • 内容表

    上一话题

    QStateMachine.SignalEvent

    下一话题

    QFinalState

    QHistoryState

    注意

    该类在 Qt4.6 引入

    概要

    详细描述

    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 状态机框架 .

    使用 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() 特性。

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

    Constructs a new history state of the given type ,采用给定 parent 状态。

    Constructs a new shallow history state with the given parent 状态。

    PySide.QtCore.QHistoryState. HistoryType

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

    常量 描述
    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 ( )
    返回类型: PySide.QtCore.QAbstractState

    This property holds the default state of this history state.

    PySide.QtCore.QHistoryState. historyType ( )
    返回类型: PySide.QtCore.QHistoryState.HistoryType

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

    此特性的默认值为 QHistoryState.ShallowHistory .

    PySide.QtCore.QHistoryState. setDefaultState ( state )
    参数: state PySide.QtCore.QAbstractState

    This property holds the default state of this history state.

    PySide.QtCore.QHistoryState. setHistoryType ( type )
    参数: type PySide.QtCore.QHistoryState.HistoryType

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

    此特性的默认值为 QHistoryState.ShallowHistory .