Sophie

Sophie

distrib > Mageia > 6 > armv5tl > media > core-updates > by-pkgid > 768f7d9f703884aa2562bf0a651086df > files > 672

qtbase5-doc-5.9.4-1.1.mga6.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qstatemachine.cpp -->
  <title>QStateMachine Class | Qt Core 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QStateMachine</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#reimplemented-public-functions">Reimplemented Public Functions</a></li>
<li class="level1"><a href="#public-slots">Public Slots</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#reimplemented-protected-functions">Reimplemented Protected Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QStateMachine Class</h1>
<!-- $$$QStateMachine-brief -->
<p>The <a href="qstatemachine.html">QStateMachine</a> class provides a hierarchical finite state machine. <a href="#details">More...</a></p>
<!-- @@@QStateMachine -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QStateMachine&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 4.6</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qstate.html">QState</a></td></tr></table></div><ul>
<li><a href="qstatemachine-members.html">List of all members, including inherited members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are reentrant.</p>
<p><b>Note:</b> These functions are also thread-safe:</p>
<ul>
<li><a href="qstatemachine.html#postEvent">postEvent</a>(QEvent *event, EventPriority priority)</li>
<li><a href="qstatemachine.html#postDelayedEvent">postDelayedEvent</a>(QEvent *event, int delay)</li>
<li><a href="qstatemachine.html#cancelDelayedEvent">cancelDelayedEvent</a>(int id)</li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine-signalevent.html">SignalEvent</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> class </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine-wrappedevent.html">WrappedEvent</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#Error-enum">Error</a></b> { NoError, NoInitialStateError, NoDefaultStateInHistoryStateError, NoCommonAncestorForTransitionError }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#EventPriority-enum">EventPriority</a></b> { NormalPriority, HighPriority }</td></tr>
</table></div>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<ul>
<li class="fn"><b><a href="qstatemachine.html#animated-prop">animated</a></b> : bool</li>
<li class="fn"><b><a href="qstatemachine.html#errorString-prop">errorString</a></b> : const QString</li>
<li class="fn"><b><a href="qstatemachine.html#globalRestorePolicy-prop">globalRestorePolicy</a></b> : QState::RestorePolicy</li>
<li class="fn"><b><a href="qstatemachine.html#running-prop">running</a></b> : bool</li>
</ul>
<ul>
<li class="fn">3 properties inherited from <a href="qstate.html#properties">QState</a></li>
<li class="fn">1 property inherited from <a href="qabstractstate.html#properties">QAbstractState</a></li>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#QStateMachine">QStateMachine</a></b>(QObject *<i>parent</i> = Q_NULLPTR)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#QStateMachine-1">QStateMachine</a></b>(QState::ChildMode <i>childMode</i>, QObject *<i>parent</i> = Q_NULLPTR)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#dtor.QStateMachine">~QStateMachine</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#addDefaultAnimation">addDefaultAnimation</a></b>(QAbstractAnimation *<i>animation</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#addState">addState</a></b>(QAbstractState *<i>state</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#cancelDelayedEvent">cancelDelayedEvent</a></b>(int <i>id</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#clearError">clearError</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QSet&lt;QAbstractState *&gt; </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#configuration">configuration</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QAbstractAnimation *&gt; </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#defaultAnimations">defaultAnimations</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Error </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#error">error</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#errorString">errorString</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QState::RestorePolicy </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#globalRestorePolicy">globalRestorePolicy</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#isAnimated">isAnimated</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#running-prop">isRunning</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#postDelayedEvent">postDelayedEvent</a></b>(QEvent *<i>event</i>, int <i>delay</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#postEvent">postEvent</a></b>(QEvent *<i>event</i>, EventPriority <i>priority</i> = NormalPriority)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#removeDefaultAnimation">removeDefaultAnimation</a></b>(QAbstractAnimation *<i>animation</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#removeState">removeState</a></b>(QAbstractState *<i>state</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#setAnimated">setAnimated</a></b>(bool <i>enabled</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#setGlobalRestorePolicy">setGlobalRestorePolicy</a></b>(QState::RestorePolicy <i>restorePolicy</i>)</td></tr>
</table></div>
<a name="reimplemented-public-functions"></a>
<h2 id="reimplemented-public-functions">Reimplemented Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#eventFilter">eventFilter</a></b>(QObject *<i>watched</i>, QEvent *<i>event</i>)</td></tr>
</table></div>
<ul>
<li class="fn">13 public functions inherited from <a href="qstate.html#public-functions">QState</a></li>
<li class="fn">3 public functions inherited from <a href="qabstractstate.html#public-functions">QAbstractState</a></li>
<li class="fn">32 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="public-slots"></a>
<h2 id="public-slots">Public Slots</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#running-prop">setRunning</a></b>(bool <i>running</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#start">start</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#stop">stop</a></b>()</td></tr>
</table></div>
<ul>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
</ul>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#runningChanged">runningChanged</a></b>(bool <i>running</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#started">started</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#stopped">stopped</a></b>()</td></tr>
</table></div>
<ul>
<li class="fn">5 signals inherited from <a href="qstate.html#signals">QState</a></li>
<li class="fn">3 signals inherited from <a href="qabstractstate.html#signals">QAbstractState</a></li>
<li class="fn">2 signals inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="reimplemented-protected-functions"></a>
<h2 id="reimplemented-protected-functions">Reimplemented Protected Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#event">event</a></b>(QEvent *<i>e</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#onEntry">onEntry</a></b>(QEvent *<i>event</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qstatemachine.html#onExit">onExit</a></b>(QEvent *<i>event</i>)</td></tr>
</table></div>
<ul>
<li class="fn">3 protected functions inherited from <a href="qstate.html#protected-functions">QState</a></li>
<li class="fn">3 protected functions inherited from <a href="qabstractstate.html#protected-functions">QAbstractState</a></li>
<li class="fn">9 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">11 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
<li class="fn">3 protected functions inherited from <a href="qstate.html#protected-functions">QState</a></li>
<li class="fn">3 protected functions inherited from <a href="qabstractstate.html#protected-functions">QAbstractState</a></li>
<li class="fn">9 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QStateMachine-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qstatemachine.html">QStateMachine</a> class provides a hierarchical finite state machine.</p>
<p><a href="qstatemachine.html">QStateMachine</a> is based on the concepts and notation of <a href="http://www.wisdom.weizmann.ac.il/~dharel/SCANNED.PAPERS/Statecharts.pdf">Statecharts</a>. <a href="qstatemachine.html">QStateMachine</a> is part of <a href="statemachine-api.html">The State Machine Framework</a>.</p>
<p>A state machine manages a set of states (classes that inherit from <a href="qabstractstate.html">QAbstractState</a>) and transitions (descendants of <a href="qabstracttransition.html">QAbstractTransition</a>) between those states; these states and transitions define a state graph. Once a state graph has been built, the state machine can execute it. <a href="qstatemachine.html">QStateMachine</a>'s execution algorithm is based on the <a href="http://www.w3.org/TR/scxml/">State Chart XML (SCXML)</a> algorithm. The framework's <a href="statemachine-api.html">overview</a> gives several state graphs and the code to build them.</p>
<p>Use the <a href="qstatemachine.html#addState">addState</a>() function to add a top-level state to the state machine. States are removed with the <a href="qstatemachine.html#removeState">removeState</a>() function. Removing states while the machine is running is discouraged.</p>
<p>Before the machine can be started, the <a href="qstate.html#initialState-prop">initial state</a> must be set. The initial state is the state that the machine enters when started. You can then <a href="qstatemachine.html#start">start</a>() the state machine. The <a href="qstatemachine.html#started">started</a>() signal is emitted when the initial state is entered.</p>
<p>The machine is event driven and keeps its own event loop. Events are posted to the machine through <a href="qstatemachine.html#postEvent">postEvent</a>(). Note that this means that it executes asynchronously, and that it will not progress without a running event loop. You will normally not have to post events to the machine directly as Qt's transitions, e.g&#x2e;, <a href="qeventtransition.html">QEventTransition</a> and its subclasses, handle this. But for custom transitions triggered by events, <a href="qstatemachine.html#postEvent">postEvent</a>() is useful.</p>
<p>The state machine processes events and takes transitions until a top-level final state is entered; the state machine then emits the <a href="qstate.html#finished">finished</a>() signal. You can also <a href="qstatemachine.html#stop">stop</a>() the state machine explicitly. The <a href="qstatemachine.html#stopped">stopped</a>() signal is emitted in this case.</p>
<p>The following snippet shows a state machine that will finish when a button is clicked:</p>
<pre class="cpp">

  <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> button;

  <span class="type"><a href="qstatemachine.html#QStateMachine">QStateMachine</a></span> machine;
  <span class="type"><a href="qstate.html#QState">QState</a></span> <span class="operator">*</span>s1 <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qstate.html#QState">QState</a></span>();
  s1<span class="operator">-</span><span class="operator">&gt;</span>assignProperty(<span class="operator">&amp;</span>button<span class="operator">,</span> <span class="string">&quot;text&quot;</span><span class="operator">,</span> <span class="string">&quot;Click me&quot;</span>);

  <span class="type"><a href="qfinalstate.html">QFinalState</a></span> <span class="operator">*</span>s2 <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qfinalstate.html">QFinalState</a></span>();
  s1<span class="operator">-</span><span class="operator">&gt;</span>addTransition(<span class="operator">&amp;</span>button<span class="operator">,</span> SIGNAL(clicked())<span class="operator">,</span> s2);

  machine<span class="operator">.</span>addState(s1);
  machine<span class="operator">.</span>addState(s2);
  machine<span class="operator">.</span>setInitialState(s1);
  machine<span class="operator">.</span>start();

</pre>
<p>This code example uses <a href="qstate.html">QState</a>, which inherits <a href="qabstractstate.html">QAbstractState</a>. The <a href="qstate.html">QState</a> class provides a state that you can use to set properties and invoke methods on <a href="qobject.html">QObject</a>s when the state is entered or exited. It also contains convenience functions for adding transitions, e.g&#x2e;, <a href="qsignaltransition.html">QSignalTransition</a>s as in this example. See the <a href="qstate.html">QState</a> class description for further details.</p>
<p>If an error is encountered, the machine will look for an <a href="qstate.html#errorState-prop">error state</a>, and if one is available, it will enter this state. The types of errors possible are described by the <a href="qstatemachine.html#Error-enum">Error</a> enum. After the error state is entered, the type of the error can be retrieved with <a href="qstatemachine.html#error">error</a>(). The execution of the state graph will not stop when the error state is entered. If no error state applies to the erroneous state, the machine will stop executing and an error message will be printed to the console.</p>
</div>
<p><b>See also </b><a href="qabstractstate.html">QAbstractState</a>, <a href="qabstracttransition.html">QAbstractTransition</a>, <a href="qstate.html">QState</a>, and <a href="statemachine-api.html">The State Machine Framework</a>.</p>
<!-- @@@QStateMachine -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$Error$$$NoError$$$NoInitialStateError$$$NoDefaultStateInHistoryStateError$$$NoCommonAncestorForTransitionError -->
<h3 class="fn" id="Error-enum"><a name="Error-enum"></a>enum QStateMachine::<span class="name">Error</span></h3>
<p>This enum type defines errors that can occur in the state machine at run time. When the state machine encounters an unrecoverable error at run time, it will set the error code returned by <a href="qstatemachine.html#error">error</a>(), the error message returned by <a href="qstatemachine.html#errorString">errorString</a>(), and enter an error state based on the context of the error.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QStateMachine::NoError</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">No error has occurred.</td></tr>
<tr><td class="topAlign"><code>QStateMachine::NoInitialStateError</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">The machine has entered a <a href="qstate.html">QState</a> with children which does not have an initial state set. The context of this error is the state which is missing an initial state.</td></tr>
<tr><td class="topAlign"><code>QStateMachine::NoDefaultStateInHistoryStateError</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign">The machine has entered a <a href="qhistorystate.html">QHistoryState</a> which does not have a default state set. The context of this error is the <a href="qhistorystate.html">QHistoryState</a> which is missing a default state.</td></tr>
<tr><td class="topAlign"><code>QStateMachine::NoCommonAncestorForTransitionError</code></td><td class="topAlign tblval"><code>3</code></td><td class="topAlign">The machine has selected a transition whose source and targets are not part of the same tree of states, and thus are not part of the same state machine. Commonly, this could mean that one of the states has not been given any parent or added to any machine. The context of this error is the source state of the transition.</td></tr>
</table></div>
<p><b>See also </b><a href="qstate.html#setErrorState">setErrorState</a>().</p>
<!-- @@@Error -->
<!-- $$$EventPriority$$$NormalPriority$$$HighPriority -->
<h3 class="fn" id="EventPriority-enum"><a name="EventPriority-enum"></a>enum QStateMachine::<span class="name">EventPriority</span></h3>
<p>This enum type specifies the priority of an event posted to the state machine using <a href="qstatemachine.html#postEvent">postEvent</a>().</p>
<p>Events of high priority are processed before events of normal priority.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QStateMachine::NormalPriority</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">The event has normal priority.</td></tr>
<tr><td class="topAlign"><code>QStateMachine::HighPriority</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">The event has high priority.</td></tr>
</table></div>
<!-- @@@EventPriority -->
</div>
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$animated-prop$$$isAnimated$$$setAnimatedbool -->
<h3 class="fn" id="animated-prop"><a name="animated-prop"></a><span class="name">animated</span> : <span class="type">bool</span></h3>
<p>This property holds whether animations are enabled</p>
<p>The default value of this property is <code>true</code>.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="qstatemachine.html#isAnimated">isAnimated</a></b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="qstatemachine.html#setAnimated">setAnimated</a></b></span>(bool <i>enabled</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qabstracttransition.html#addAnimation">QAbstractTransition::addAnimation</a>().</p>
<!-- @@@animated -->
<!-- $$$errorString-prop$$$errorString -->
<h3 class="fn" id="errorString-prop"><a name="errorString-prop"></a><span class="name">errorString</span> : const <span class="type"><a href="qstring.html">QString</a></span></h3>
<p>This property holds the error string of this state machine</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="qstatemachine.html#errorString">errorString</a></b></span>() const</td></tr>
</table></div>
<!-- @@@errorString -->
<!-- $$$globalRestorePolicy-prop$$$globalRestorePolicy$$$setGlobalRestorePolicyQState::RestorePolicy -->
<h3 class="fn" id="globalRestorePolicy-prop"><a name="globalRestorePolicy-prop"></a><span class="name">globalRestorePolicy</span> : <span class="type"><a href="qstate.html#RestorePolicy-enum">QState::RestorePolicy</a></span></h3>
<p>This property holds the restore policy for states of this state machine.</p>
<p>The default value of this property is <a href="qstate.html#RestorePolicy-enum">QState::DontRestoreProperties</a>.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QState::RestorePolicy </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="qstatemachine.html#globalRestorePolicy">globalRestorePolicy</a></b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="qstatemachine.html#setGlobalRestorePolicy">setGlobalRestorePolicy</a></b></span>(QState::RestorePolicy <i>restorePolicy</i>)</td></tr>
</table></div>
<!-- @@@globalRestorePolicy -->
<!-- $$$running-prop$$$isRunning$$$setRunningbool$$$runningChangedbool -->
<h3 class="fn" id="running-prop"><a name="running-prop"></a><span class="name">running</span> : <span class="type">bool</span></h3>
<p>This property holds the running state of this state machine</p>
<p>This property was introduced in  Qt 5.4.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> bool </td><td class="memItemRight bottomAlign"><span class="name"><b>isRunning</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setRunning</b></span>(bool <i>running</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="qstatemachine.html#runningChanged">runningChanged</a></b></span>(bool <i>running</i>)</td></tr>
</table></div>
<p><b>See also </b><a href="qstatemachine.html#start">start</a>(), <a href="qstatemachine.html#stop">stop</a>(), <a href="qstatemachine.html#started">started</a>(), <a href="qstatemachine.html#stopped">stopped</a>(), and <a href="qstatemachine.html#runningChanged">runningChanged</a>().</p>
<!-- @@@running -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QStateMachine[overload1]$$$QStateMachineQObject* -->
<h3 class="fn" id="QStateMachine"><a name="QStateMachine"></a>QStateMachine::<span class="name">QStateMachine</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_NULLPTR)</h3>
<p>Constructs a new state machine with the given <i>parent</i>.</p>
<!-- @@@QStateMachine -->
<!-- $$$QStateMachine$$$QStateMachineQState::ChildModeQObject* -->
<h3 class="fn" id="QStateMachine-1"><a name="QStateMachine-1"></a>QStateMachine::<span class="name">QStateMachine</span>(<span class="type"><a href="qstate.html#ChildMode-enum">QState::ChildMode</a></span> <i>childMode</i>, <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_NULLPTR)</h3>
<p>Constructs a new state machine with the given <i>childMode</i> and <i>parent</i>.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@QStateMachine -->
<!-- $$$~QStateMachine[overload1]$$$~QStateMachine -->
<h3 class="fn" id="dtor.QStateMachine"><a name="dtor.QStateMachine"></a>QStateMachine::<span class="name">~QStateMachine</span>()</h3>
<p>Destroys this state machine.</p>
<!-- @@@~QStateMachine -->
<!-- $$$addDefaultAnimation[overload1]$$$addDefaultAnimationQAbstractAnimation* -->
<h3 class="fn" id="addDefaultAnimation"><a name="addDefaultAnimation"></a><span class="type">void</span> QStateMachine::<span class="name">addDefaultAnimation</span>(<span class="type"><a href="qabstractanimation.html">QAbstractAnimation</a></span> *<i>animation</i>)</h3>
<p>Adds a default <i>animation</i> to be considered for any transition.</p>
<!-- @@@addDefaultAnimation -->
<!-- $$$addState[overload1]$$$addStateQAbstractState* -->
<h3 class="fn" id="addState"><a name="addState"></a><span class="type">void</span> QStateMachine::<span class="name">addState</span>(<span class="type"><a href="qabstractstate.html#QAbstractState">QAbstractState</a></span> *<i>state</i>)</h3>
<p>Adds the given <i>state</i> to this state machine. The state becomes a top-level state.</p>
<p>If the state is already in a different machine, it will first be removed from its old machine, and then added to this machine.</p>
<p><b>See also </b><a href="qstatemachine.html#removeState">removeState</a>() and <a href="qstate.html#setInitialState">setInitialState</a>().</p>
<!-- @@@addState -->
<!-- $$$cancelDelayedEvent[overload1]$$$cancelDelayedEventint -->
<h3 class="fn" id="cancelDelayedEvent"><a name="cancelDelayedEvent"></a><span class="type">bool</span> QStateMachine::<span class="name">cancelDelayedEvent</span>(<span class="type">int</span> <i>id</i>)</h3>
<p>Cancels the delayed event identified by the given <i>id</i>. The id should be a value returned by a call to <a href="qstatemachine.html#postDelayedEvent">postDelayedEvent</a>(). Returns <code>true</code> if the event was successfully cancelled, otherwise returns <code>false</code>.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<p><b>See also </b><a href="qstatemachine.html#postDelayedEvent">postDelayedEvent</a>().</p>
<!-- @@@cancelDelayedEvent -->
<!-- $$$clearError[overload1]$$$clearError -->
<h3 class="fn" id="clearError"><a name="clearError"></a><span class="type">void</span> QStateMachine::<span class="name">clearError</span>()</h3>
<p>Clears the error string and error code of the state machine.</p>
<!-- @@@clearError -->
<!-- $$$configuration[overload1]$$$configuration -->
<h3 class="fn" id="configuration"><a name="configuration"></a><span class="type"><a href="qset.html">QSet</a></span>&lt;<span class="type"><a href="qabstractstate.html#QAbstractState">QAbstractState</a></span> *&gt; QStateMachine::<span class="name">configuration</span>() const</h3>
<p>Returns the maximal consistent set of states (including parallel and final states) that this state machine is currently in. If a state <code>s</code> is in the configuration, it is always the case that the parent of <code>s</code> is also in c. Note, however, that the machine itself is not an explicit member of the configuration.</p>
<!-- @@@configuration -->
<!-- $$$defaultAnimations[overload1]$$$defaultAnimations -->
<h3 class="fn" id="defaultAnimations"><a name="defaultAnimations"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type"><a href="qabstractanimation.html">QAbstractAnimation</a></span> *&gt; QStateMachine::<span class="name">defaultAnimations</span>() const</h3>
<p>Returns the list of default animations that will be considered for any transition.</p>
<!-- @@@defaultAnimations -->
<!-- $$$error[overload1]$$$error -->
<h3 class="fn" id="error"><a name="error"></a><span class="type"><a href="qstatemachine.html#Error-enum">Error</a></span> QStateMachine::<span class="name">error</span>() const</h3>
<p>Returns the error code of the last error that occurred in the state machine.</p>
<!-- @@@error -->
<!-- $$$errorString -->
<h3 class="fn" id="errorString"><a name="errorString"></a><span class="type"><a href="qstring.html">QString</a></span> QStateMachine::<span class="name">errorString</span>() const</h3>
<p>Returns the error string of the last error that occurred in the state machine.</p>
<p><b>Note:</b> Getter function for property <a href="qstatemachine.html#errorString-prop">errorString</a>. </p><!-- @@@errorString -->
<!-- $$$event[overload1]$$$eventQEvent* -->
<h3 class="fn" id="event"><a name="event"></a><code>[virtual protected] </code><span class="type">bool</span> QStateMachine::<span class="name">event</span>(<span class="type"><a href="qevent.html">QEvent</a></span> *<i>e</i>)</h3>
<p>Reimplemented from <a href="qobject.html#event">QObject::event</a>().</p>
<!-- @@@event -->
<!-- $$$eventFilter[overload1]$$$eventFilterQObject*QEvent* -->
<h3 class="fn" id="eventFilter"><a name="eventFilter"></a><code>[virtual] </code><span class="type">bool</span> QStateMachine::<span class="name">eventFilter</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>watched</i>, <span class="type"><a href="qevent.html">QEvent</a></span> *<i>event</i>)</h3>
<p>Reimplemented from <a href="qobject.html#eventFilter">QObject::eventFilter</a>().</p>
<!-- @@@eventFilter -->
<!-- $$$globalRestorePolicy -->
<h3 class="fn" id="globalRestorePolicy"><a name="globalRestorePolicy"></a><span class="type"><a href="qstate.html#RestorePolicy-enum">QState::RestorePolicy</a></span> QStateMachine::<span class="name">globalRestorePolicy</span>() const</h3>
<p>Returns the restore policy of the state machine.</p>
<p><b>Note:</b> Getter function for property <a href="qstatemachine.html#globalRestorePolicy-prop">globalRestorePolicy</a>. </p><p><b>See also </b><a href="qstatemachine.html#setGlobalRestorePolicy">setGlobalRestorePolicy</a>().</p>
<!-- @@@globalRestorePolicy -->
<!-- $$$isAnimated -->
<h3 class="fn" id="isAnimated"><a name="isAnimated"></a><span class="type">bool</span> QStateMachine::<span class="name">isAnimated</span>() const</h3>
<p>Returns whether animations are enabled for this state machine.</p>
<p><b>Note:</b> Getter function for property <a href="qstatemachine.html#animated-prop">animated</a>. </p><!-- @@@isAnimated -->
<!-- $$$onEntry[overload1]$$$onEntryQEvent* -->
<h3 class="fn" id="onEntry"><a name="onEntry"></a><code>[virtual protected] </code><span class="type">void</span> QStateMachine::<span class="name">onEntry</span>(<span class="type"><a href="qevent.html">QEvent</a></span> *<i>event</i>)</h3>
<p>Reimplemented from <a href="qabstractstate.html#onEntry">QAbstractState::onEntry</a>().</p>
<p>This function will call <a href="qstatemachine.html#start">start</a>() to start the state machine.</p>
<!-- @@@onEntry -->
<!-- $$$onExit[overload1]$$$onExitQEvent* -->
<h3 class="fn" id="onExit"><a name="onExit"></a><code>[virtual protected] </code><span class="type">void</span> QStateMachine::<span class="name">onExit</span>(<span class="type"><a href="qevent.html">QEvent</a></span> *<i>event</i>)</h3>
<p>Reimplemented from <a href="qabstractstate.html#onExit">QAbstractState::onExit</a>().</p>
<p>This function will call <a href="qstatemachine.html#stop">stop</a>() to stop the state machine and subsequently emit the <a href="qstatemachine.html#stopped">stopped</a>() signal.</p>
<!-- @@@onExit -->
<!-- $$$postDelayedEvent[overload1]$$$postDelayedEventQEvent*int -->
<h3 class="fn" id="postDelayedEvent"><a name="postDelayedEvent"></a><span class="type">int</span> QStateMachine::<span class="name">postDelayedEvent</span>(<span class="type"><a href="qevent.html">QEvent</a></span> *<i>event</i>, <span class="type">int</span> <i>delay</i>)</h3>
<p>Posts the given <i>event</i> for processing by this state machine, with the given <i>delay</i> in milliseconds. Returns an identifier associated with the delayed event, or -1 if the event could not be posted.</p>
<p>This function returns immediately. When the delay has expired, the event will be added to the state machine's event queue for processing. The state machine takes ownership of the event and deletes it once it has been processed.</p>
<p>You can only post events when the state machine is running.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<p><b>See also </b><a href="qstatemachine.html#cancelDelayedEvent">cancelDelayedEvent</a>() and <a href="qstatemachine.html#postEvent">postEvent</a>().</p>
<!-- @@@postDelayedEvent -->
<!-- $$$postEvent[overload1]$$$postEventQEvent*EventPriority -->
<h3 class="fn" id="postEvent"><a name="postEvent"></a><span class="type">void</span> QStateMachine::<span class="name">postEvent</span>(<span class="type"><a href="qevent.html">QEvent</a></span> *<i>event</i>, <span class="type"><a href="qstatemachine.html#EventPriority-enum">EventPriority</a></span> <i>priority</i> = NormalPriority)</h3>
<p>Posts the given <i>event</i> of the given <i>priority</i> for processing by this state machine.</p>
<p>This function returns immediately. The event is added to the state machine's event queue. Events are processed in the order posted. The state machine takes ownership of the event and deletes it once it has been processed.</p>
<p>You can only post events when the state machine is running or when it is starting up.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<p><b>See also </b><a href="qstatemachine.html#postDelayedEvent">postDelayedEvent</a>().</p>
<!-- @@@postEvent -->
<!-- $$$removeDefaultAnimation[overload1]$$$removeDefaultAnimationQAbstractAnimation* -->
<h3 class="fn" id="removeDefaultAnimation"><a name="removeDefaultAnimation"></a><span class="type">void</span> QStateMachine::<span class="name">removeDefaultAnimation</span>(<span class="type"><a href="qabstractanimation.html">QAbstractAnimation</a></span> *<i>animation</i>)</h3>
<p>Removes <i>animation</i> from the list of default animations.</p>
<!-- @@@removeDefaultAnimation -->
<!-- $$$removeState[overload1]$$$removeStateQAbstractState* -->
<h3 class="fn" id="removeState"><a name="removeState"></a><span class="type">void</span> QStateMachine::<span class="name">removeState</span>(<span class="type"><a href="qabstractstate.html#QAbstractState">QAbstractState</a></span> *<i>state</i>)</h3>
<p>Removes the given <i>state</i> from this state machine. The state machine releases ownership of the state.</p>
<p><b>See also </b><a href="qstatemachine.html#addState">addState</a>().</p>
<!-- @@@removeState -->
<!-- $$$runningChanged -->
<h3 class="fn" id="runningChanged"><a name="runningChanged"></a><code>[signal] </code><span class="type">void</span> QStateMachine::<span class="name">runningChanged</span>(<span class="type">bool</span> <i>running</i>)</h3>
<p>This signal is emitted when the running property is changed with <i>running</i> as argument.</p>
<p>This function was introduced in  Qt 5.4.</p>
<p><b>Note:</b> Notifier signal for property <a href="qstatemachine.html#running-prop">running</a>. </p><p><b>See also </b><a href="qstatemachine.html#running-prop">QStateMachine::running</a>.</p>
<!-- @@@runningChanged -->
<!-- $$$setAnimated -->
<h3 class="fn" id="setAnimated"><a name="setAnimated"></a><span class="type">void</span> QStateMachine::<span class="name">setAnimated</span>(<span class="type">bool</span> <i>enabled</i>)</h3>
<p>Sets whether animations are <i>enabled</i> for this state machine.</p>
<p><b>Note:</b> Setter function for property <a href="qstatemachine.html#animated-prop">animated</a>. </p><p><b>See also </b><a href="qstatemachine.html#isAnimated">isAnimated</a>().</p>
<!-- @@@setAnimated -->
<!-- $$$setGlobalRestorePolicy -->
<h3 class="fn" id="setGlobalRestorePolicy"><a name="setGlobalRestorePolicy"></a><span class="type">void</span> QStateMachine::<span class="name">setGlobalRestorePolicy</span>(<span class="type"><a href="qstate.html#RestorePolicy-enum">QState::RestorePolicy</a></span> <i>restorePolicy</i>)</h3>
<p>Sets the restore policy of the state machine to <i>restorePolicy</i>. The default restore policy is <a href="qstate.html#RestorePolicy-enum">QState::DontRestoreProperties</a>.</p>
<p><b>Note:</b> Setter function for property <a href="qstatemachine.html#globalRestorePolicy-prop">globalRestorePolicy</a>. </p><p><b>See also </b><a href="qstatemachine.html#globalRestorePolicy">globalRestorePolicy</a>().</p>
<!-- @@@setGlobalRestorePolicy -->
<!-- $$$start[overload1]$$$start -->
<h3 class="fn" id="start"><a name="start"></a><code>[slot] </code><span class="type">void</span> QStateMachine::<span class="name">start</span>()</h3>
<p>Starts this state machine. The machine will reset its configuration and transition to the initial state. When a final top-level state (<a href="qfinalstate.html">QFinalState</a>) is entered, the machine will emit the <a href="qstate.html#finished">finished</a>() signal.</p>
<p><b>Note: </b>A state machine will not run without a running event loop, such as the main application event loop started with <a href="qcoreapplication.html#exec">QCoreApplication::exec</a>() or <a href="../qtwidgets/qapplication.html#exec">QApplication::exec</a>().</p><p><b>See also </b><a href="qstatemachine.html#started">started</a>(), <a href="qstate.html#finished">finished</a>(), <a href="qstatemachine.html#stop">stop</a>(), <a href="qstate.html#initialState">initialState</a>(), and <a href="qstatemachine.html#running-prop">setRunning</a>().</p>
<!-- @@@start -->
<!-- $$$started[overload1]$$$started -->
<h3 class="fn" id="started"><a name="started"></a><code>[signal] </code><span class="type">void</span> QStateMachine::<span class="name">started</span>()</h3>
<p>This signal is emitted when the state machine has entered its initial state (<a href="qstate.html#initialState-prop">QStateMachine::initialState</a>).</p>
<p><b>Note: </b>This is a private signal. It can be used in signal connections but cannot be emitted by the user.</p>
<p><b>See also </b><a href="qstate.html#finished">QStateMachine::finished</a>() and <a href="qstatemachine.html#start">QStateMachine::start</a>().</p>
<!-- @@@started -->
<!-- $$$stop[overload1]$$$stop -->
<h3 class="fn" id="stop"><a name="stop"></a><code>[slot] </code><span class="type">void</span> QStateMachine::<span class="name">stop</span>()</h3>
<p>Stops this state machine. The state machine will stop processing events and then emit the <a href="qstatemachine.html#stopped">stopped</a>() signal.</p>
<p><b>See also </b><a href="qstatemachine.html#stopped">stopped</a>(), <a href="qstatemachine.html#start">start</a>(), and <a href="qstatemachine.html#running-prop">setRunning</a>().</p>
<!-- @@@stop -->
<!-- $$$stopped[overload1]$$$stopped -->
<h3 class="fn" id="stopped"><a name="stopped"></a><code>[signal] </code><span class="type">void</span> QStateMachine::<span class="name">stopped</span>()</h3>
<p>This signal is emitted when the state machine has stopped.</p>
<p><b>Note: </b>This is a private signal. It can be used in signal connections but cannot be emitted by the user.</p>
<p><b>See also </b><a href="qstatemachine.html#stop">QStateMachine::stop</a>() and <a href="qstate.html#finished">QStateMachine::finished</a>().</p>
<!-- @@@stopped -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>