CopperSpice API  1.9.1
QHistoryState Class Reference

Provides a means of returning to a previously active substate. More...

Inheritance diagram for QHistoryState:
QAbstractState QObject

Public Types

enum  HistoryType
 

Public Signals

void defaultStateChanged ()
 
void defaultTransitionChanged ()
 
void historyTypeChanged ()
 
- Public Signals inherited from QAbstractState
void activeChanged (bool active)
 
void entered ()
 
void exited ()
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Methods

 QHistoryState (HistoryType type, QState *parent=nullptr)
 
 QHistoryState (QState *parent=nullptr)
 
 ~QHistoryState ()
 
QAbstractStatedefaultState () const
 
QAbstractTransitiondefaultTransition () const
 
HistoryType historyType () const
 
void setDefaultState (QAbstractState *state)
 
void setDefaultTransition (QAbstractTransition *transition)
 
void setHistoryType (HistoryType type)
 
- Public Methods inherited from QAbstractState
 ~QAbstractState ()
 
bool active () const
 
QStateMachinemachine () const
 
QStateparentState () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 

Protected Methods

bool event (QEvent *event) override
 
void onEntry (QEvent *event) override
 
void onExit (QEvent *event) override
 
- Protected Methods inherited from QAbstractState
 QAbstractState (QState *parent=nullptr)
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Properties

 defaultState
 
 defaultTransition
 
 historyType
 
- Properties inherited from QAbstractState
 active
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 

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 State Machine.

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

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

QState *s1 = new QState();
QState *s2 = new QState(s1);
QHistoryState *s1_hist = new QHistoryState(s1);
s1h->setDefaultState(s2);
QState *s3 = new QState();
// 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.
QPushButton *button = new QPushButton();
s1->addTransition(button, SIGNAL(clicked()), s1_hist);

Member Enumeration Documentation

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

ConstantValueDescription
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.

Constructor & Destructor Documentation

QHistoryState::QHistoryState ( QState parent = nullptr)

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

QHistoryState::QHistoryState ( HistoryType  type,
QState parent = nullptr 
)

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

QHistoryState::~QHistoryState ( )

Destroys this history state.

Method Documentation

QAbstractState * QHistoryState::defaultState ( ) const

Returns the value of the defaultState property. The default state indicates the state to transition to if the parent state has never been entered before.

See also
setDefaultState()
void QHistoryState::defaultStateChanged ( )
signal

This signal is emitted when the defaultState property is changed.

See also
QHistoryState::defaultState
QAbstractTransition * QHistoryState::defaultTransition ( ) const

Returns this history state's default transition. The default transition is taken when the history state has never been entered before. The target states of the default transition therefore make up the default state.

See also
setDefaultTransition()
void QHistoryState::defaultTransitionChanged ( )
signal

This signal is emitted when the defaultTransition property is changed.

See also
QHistoryState::defaultTransition
bool QHistoryState::event ( QEvent event)
overrideprotectedvirtual

Reimplemented from QAbstractState::event()

HistoryType QHistoryState::historyType ( ) const

Returns the value of the defaultType property.

void QHistoryState::historyTypeChanged ( )
signal

This signal is emitted when the historyType property is changed.

See also
QHistoryState::historyType
void QHistoryState::onEntry ( QEvent event)
overrideprotectedvirtual
void QHistoryState::onExit ( QEvent event)
overrideprotectedvirtual
void QHistoryState::setDefaultState ( QAbstractState state)

Sets this history state's default state to the given state. The state must be a sibling of this QHistoryState. This method does not use the given state for the initial state of its parent.

See also
defaultState()
void QHistoryState::setDefaultTransition ( QAbstractTransition transition)

Sets this history state's default transition to be the given transition. This will set the source state of the transition to the history state. The eventTest method of the transition will never be called.

See also
defaultTransition()
void QHistoryState::setHistoryType ( HistoryType  type)

Sets the type of history this QHistoryState records.

See also
historyType()

Property Documentation

QHistoryState::defaultState

This property holds the default state of this history state.

PropertiesClass Methods
read defaultState
write setDefaultState
notify defaultStateChanged
QHistoryState::defaultTransition

This property holds the default transition of this history state.

PropertiesClass Methods
read defaultTransition
write setDefaultTransition
notify defaultTransitionChanged
QHistoryState::historyType

This property holds the type of history that this history state records. The default value of this property is QHistoryState::ShallowHistory.

PropertiesClass Methods
read historyType
write setHistoryType
notify historyTypeChanged