<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qscxmlstatemachine.cpp --> <title>ScxmlStateMachine QML Type | Qt SCXML 5.12.6</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.12</td><td ><a href="qtscxml-index.html">Qt SCXML</a></td><td ><a href="qtscxml-qmlmodule.html">QML Types</a></td><td >ScxmlStateMachine QML Type</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtscxml-index.html">Qt 5.12.6 Reference Documentation</a></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="#properties">Properties</a></li> <li class="level1"><a href="#signals">Signals</a></li> <li class="level1"><a href="#methods">Methods</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">ScxmlStateMachine QML Type</h1> <span class="subtitle"></span> <!-- $$$ScxmlStateMachine-brief --> <p>Provides an interface to the state machines created from SCXML files. <a href="#details">More...</a></p> <!-- @@@ScxmlStateMachine --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import QtScxml 5.8</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign"> Qt 5.7</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Instantiates:</td><td class="memItemRight bottomAlign"> <a href="qml-qtscxml-scxmlstatemachine.html"><a href="qscxmlstatemachine.html">QScxmlStateMachine</a></td></tr></table></div><ul> <li><a href="qml-qtscxml-scxmlstatemachine-members.html">List of all members, including inherited members</a></li> </ul> <a name="properties"></a> <h2 id="properties">Properties</h2> <ul> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#dataModel-prop">dataModel</a></b></b> : ScxmlDataModel</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#initialValues-prop">initialValues</a></b></b> : var</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#initialized-prop">initialized</a></b></b> : bool</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#invoked-prop">invoked</a></b></b> : bool</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#invokedServices-prop">invokedServices</a></b></b> : list</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#loader-prop">loader</a></b></b> : Loader</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#name-prop">name</a></b></b> : string</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#parseErrors-prop">parseErrors</a></b></b> : var</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#running-prop">running</a></b></b> : bool</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#sessionId-prop">sessionId</a></b></b> : string</li> </ul> <a name="signals"></a> <h2 id="signals">Signals</h2> <ul> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#finished-signal">finished</a></b></b>()</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#log-signal">log</a></b></b>(string <i>label</i>, string <i>msg</i>)</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#reachedStableState-signal">reachedStableState</a></b></b>()</li> </ul> <a name="methods"></a> <h2 id="methods">Methods</h2> <ul> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#activeStateNames-method">activeStateNames</a></b></b>(bool <i>compress</i>)</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#cancelDelayedEvent-method">cancelDelayedEvent</a></b></b>(string <i>sendId</i>)</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#init-method">init</a></b></b>()</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#isActive-method">isActive</a></b></b>(string <i>scxmlStateName</i>)</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#isDispatchableTarget-method">isDispatchableTarget</a></b></b>(string <i>target</i>)</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#start-method">start</a></b></b>()</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#stateNames-method">stateNames</a></b></b>(bool <i>compress</i>)</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#stop-method">stop</a></b></b>()</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#submitEvent-method">submitEvent</a></b></b>(<i>event</i>)</li> <li class="fn"><b><b><a href="qml-qtscxml-scxmlstatemachine.html#submitEvent-method-1">submitEvent</a></b></b>(string <i>eventName</i>, var <i>data</i>)</li> </ul> <!-- $$$ScxmlStateMachine-description --> <a name="details"></a> <h2 id="details">Detailed Description</h2> <p>The <a href="qml-qtscxml-scxmlstatemachine.html">ScxmlStateMachine</a> type is an implementation of the <a href="http://www.w3.org/TR/scxml/">State Chart XML (SCXML)</a>.</p> <p>All states that are defined in the SCXML file are accessible as properties of this type. These properties are boolean values and indicate whether the state is active or inactive.</p> <!-- @@@ScxmlStateMachine --> <h2>Property Documentation</h2> <!-- $$$dataModel --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="dataModel-prop"> <td class="tblQmlPropNode"><p> <a name="dataModel-prop"></a><span class="name">dataModel</span> : <span class="type">ScxmlDataModel</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The data model to be used for this state machine.</p> <p>SCXML data models are described in <a href="https://www.w3.org/TR/scxml/#data-module">SCXML Specification - 5 Data Model and Data Manipulation</a>. For more information about supported data models, see <a href="qtscxml-scxml-compliance.html">SCXML Compliance</a>.</p> <p>Changing the data model when the state machine has been <a href="qml-qtscxml-scxmlstatemachine.html#initialized-prop">initialized</a> is not specified in the SCXML standard and leads to undefined behavior.</p> <p><b>See also </b><a href="qscxmldatamodel.html">QScxmlDataModel</a>, <a href="qscxmlnulldatamodel.html">QScxmlNullDataModel</a>, <a href="qscxmlecmascriptdatamodel.html">QScxmlEcmaScriptDataModel</a>, and <a href="qscxmlcppdatamodel.html">QScxmlCppDataModel</a>.</p> </div></div><!-- @@@dataModel --> <br/> <!-- $$$initialValues --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="initialValues-prop"> <td class="tblQmlPropNode"><p> <a name="initialValues-prop"></a><span class="name">initialValues</span> : <span class="type">var</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The initial values to be used for setting up the data model.</p> </div></div><!-- @@@initialValues --> <br/> <!-- $$$initialized --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="initialized-prop"> <td class="tblQmlPropNode"><p> <a name="initialized-prop"></a><span class="name">initialized</span> : <span class="type">bool</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>This read-only property is set to <code>true</code> if the state machine has been initialized, <code>false</code> otherwise.</p> </div></div><!-- @@@initialized --> <br/> <!-- $$$invoked --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="invoked-prop"> <td class="tblQmlPropNode"><p> <a name="invoked-prop"></a><span class="name">invoked</span> : <span class="type">bool</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>Whether the state machine was invoked from an outer state machine.</p> <p>This read-only property is set to <code>true</code> when the state machine was started as a service with the <code><invoke></code> element, <code>false</code> otherwise.</p> </div></div><!-- @@@invoked --> <br/> <!-- $$$invokedServices --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="invokedServices-prop"> <td class="tblQmlPropNode"><p> <a name="invokedServices-prop"></a><span class="name">invokedServices</span> : <span class="type">list</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>A list of SCXML services that were invoked from the main state machine (possibly recursively).</p> </div></div><!-- @@@invokedServices --> <br/> <!-- $$$loader --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="loader-prop"> <td class="tblQmlPropNode"><p> <a name="loader-prop"></a><span class="name">loader</span> : <span class="type">Loader</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The loader that is currently used to resolve and load URIs for the state machine.</p> </div></div><!-- @@@loader --> <br/> <!-- $$$name --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="name-prop"> <td class="tblQmlPropNode"><p> <a name="name-prop"></a><span class="name">name</span> : <span class="type">string</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The name of the state machine as set by the <i>name</i> attribute of the <code><scxml></code> tag.</p> </div></div><!-- @@@name --> <br/> <!-- $$$parseErrors --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="parseErrors-prop"> <td class="tblQmlPropNode"><p> <a name="parseErrors-prop"></a><span class="name">parseErrors</span> : <span class="type">var</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The list of parse errors that occurred while creating a state machine from an SCXML file.</p> </div></div><!-- @@@parseErrors --> <br/> <!-- $$$running --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="running-prop"> <td class="tblQmlPropNode"><p> <a name="running-prop"></a><span class="name">running</span> : <span class="type">bool</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The running state of this state machine.</p> </div></div><!-- @@@running --> <br/> <!-- $$$sessionId --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="sessionId-prop"> <td class="tblQmlPropNode"><p> <a name="sessionId-prop"></a><span class="name">sessionId</span> : <span class="type">string</span></p></td></tr> </table></div> </div><div class="qmldoc"><p>The session ID of the current state machine.</p> <p>The session ID is used for message routing between parent and child state machines. If a state machine is started by an <code><invoke></code> element, any event it sends will have the <code>invokeid</code> field set to the session ID. The state machine will use the origin of an event (which is set by the <i>target</i> or <i>targetexpr</i> attribute in a <code><send></code> element) to dispatch messages to the correct child state machine.</p> </div></div><!-- @@@sessionId --> <br/> <h2>Signal Documentation</h2> <!-- $$$finished --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="finished-signal"> <td class="tblQmlFuncNode"><p> <a name="finished-signal"></a><span class="name">finished</span>()</p></td></tr> </table></div> </div><div class="qmldoc"><p>This signal is emitted when the state machine reaches a top-level final state.</p> <p>The corresponding signal handler is <code>onFinished()</code>.</p> </div></div><!-- @@@finished --> <br/> <!-- $$$log --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="log-signal"> <td class="tblQmlFuncNode"><p> <a name="log-signal"></a><span class="name">log</span>(<span class="type">string</span> <i>label</i>, <span class="type">string</span> <i>msg</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>This signal is emitted if a <code><log></code> tag is used in the SCXML. <i>label</i> is the value of the <i>label</i> attribute of the <code><log></code> tag. <i>msg</i> is the value of the evaluated <i>expr</i> attribute of the <code><log></code> tag. If there is no <i>expr</i> attribute, a null string will be returned.</p> <p>The corresponding signal handler is <code>onLog()</code>.</p> </div></div><!-- @@@log --> <br/> <!-- $$$reachedStableState --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="reachedStableState-signal"> <td class="tblQmlFuncNode"><p> <a name="reachedStableState-signal"></a><span class="name">reachedStableState</span>()</p></td></tr> </table></div> </div><div class="qmldoc"><p>This signal is emitted when the event queue is empty at the end of a macro step or when a final state is reached.</p> <p>The corresponding signal handler is <code>onreachedStableState()</code>.</p> </div></div><!-- @@@reachedStableState --> <br/> <h2>Method Documentation</h2> <!-- $$$activeStateNames --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="activeStateNames-method"> <td class="tblQmlFuncNode"><p> <a name="activeStateNames-method"></a><span class="name">activeStateNames</span>(<span class="type">bool</span> <i>compress</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>Retrieves a list of state names of all active states.</p> <p>When a state is active, all its parent states are active by definition. When <i>compress</i> is <code>true</code> (the default), the parent states are filtered out and only the <i>leaf states</i> are returned. When it is <code>false</code>, the full list of active states is returned.</p> </div></div><!-- @@@activeStateNames --> <br/> <!-- $$$cancelDelayedEvent --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="cancelDelayedEvent-method"> <td class="tblQmlFuncNode"><p> <a name="cancelDelayedEvent-method"></a><span class="name">cancelDelayedEvent</span>(<span class="type">string</span> <i>sendId</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>Cancels a delayed event with the specified <i>sendId</i>.</p> </div></div><!-- @@@cancelDelayedEvent --> <br/> <!-- $$$init --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="init-method"> <td class="tblQmlFuncNode"><p> <a name="init-method"></a><span class="name">init</span>()</p></td></tr> </table></div> </div><div class="qmldoc"><p>Initializes the state machine by setting the initial values for <code><data></code> elements and executing any <code><script></code> tags of the <code><scxml></code> tag. The initial data values are taken from the <a href="qml-qtscxml-scxmlstatemachine.html#initialValues-prop">initialValues</a> property.</p> <p>Returns <code>false</code> if parse errors occur or if any of the initialization steps fail. Returns <code>true</code> otherwise.</p> </div></div><!-- @@@init --> <br/> <!-- $$$isActive --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="isActive-method"> <td class="tblQmlFuncNode"><p> <a name="isActive-method"></a><span class="name">isActive</span>(<span class="type">string</span> <i>scxmlStateName</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>Returns <code>true</code> if the state specified by <i>scxmlStateName</i> is active, <code>false</code> otherwise.</p> </div></div><!-- @@@isActive --> <br/> <!-- $$$isDispatchableTarget --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="isDispatchableTarget-method"> <td class="tblQmlFuncNode"><p> <a name="isDispatchableTarget-method"></a><span class="name">isDispatchableTarget</span>(<span class="type">string</span> <i>target</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>Returns <code>true</code> if a message to <i>target</i> can be dispatched by this state machine.</p> <p>Valid targets are:</p> <ul> <li><code>#_parent</code> for the parent state machine if the current state machine is started by <code><invoke></code></li> <li><code>#_internal</code> for the current state machine</li> <li><code>#_scxml_sessionid</code>, where <code>sessionid</code> is the session ID of the current state machine</li> <li><code>#_servicename</code>, where <code>servicename</code> is the ID or name of a service started with <code><invoke></code> by this state machine</li> </ul> </div></div><!-- @@@isDispatchableTarget --> <br/> <!-- $$$start --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="start-method"> <td class="tblQmlFuncNode"><p> <a name="start-method"></a><span class="name">start</span>()</p></td></tr> </table></div> </div><div class="qmldoc"><p>Starts this state machine. The machine resets its configuration and transitions to the initial state. When a final top-level state is entered, the machine emits the <a href="qml-qtscxml-scxmlstatemachine.html#finished-signal">finished()</a> signal.</p> <p><b>See also </b><a href="qml-qtscxml-scxmlstatemachine.html#stop-method">stop()</a> and <a href="qml-qtscxml-scxmlstatemachine.html#finished-signal">finished()</a>.</p> </div></div><!-- @@@start --> <br/> <!-- $$$stateNames --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="stateNames-method"> <td class="tblQmlFuncNode"><p> <a name="stateNames-method"></a><span class="name">stateNames</span>(<span class="type">bool</span> <i>compress</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>Retrieves a list of state names of all states.</p> <p>When <i>compress</i> is <code>true</code> (the default), the states that contain child states is filtered out and only the <i>leaf states</i> is returned. When it is <code>false</code>, the full list of all states is returned.</p> <p>The returned list does not contain the states of possible nested state machines.</p> <p><b>Note: </b>The order of the state names in the list is the order in which the states occurred in the SCXML document.</p></div></div><!-- @@@stateNames --> <br/> <!-- $$$stop --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="stop-method"> <td class="tblQmlFuncNode"><p> <a name="stop-method"></a><span class="name">stop</span>()</p></td></tr> </table></div> </div><div class="qmldoc"><p>Stops this state machine. The machine will not execute any further state transitions. Its <a href="qml-qtscxml-scxmlstatemachine.html#running-prop">running</a> property is set to <code>false</code>.</p> <p><b>See also </b><a href="qml-qtscxml-scxmlstatemachine.html#start-method">start()</a> and <a href="qml-qtscxml-scxmlstatemachine.html#finished-signal">finished()</a>.</p> </div></div><!-- @@@stop --> <br/> <!-- $$$submitEvent --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="submitEvent-method"> <td class="tblQmlFuncNode"><p> <a name="submitEvent-method"></a><span class="name">submitEvent</span>(<i>event</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>Submits the SCXML event <i>event</i> to the internal or external event queue depending on the priority of the event.</p> <p>When a delay is set, the event will be queued for delivery after the timeout has passed. The state machine takes ownership of the event and deletes it after processing.</p> <p><b>See also </b><a href="qscxmlevent.html">QScxmlEvent</a>.</p> </div></div><!-- @@@submitEvent --> <br/> <!-- $$$submitEvent --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="submitEvent-method-1"> <td class="tblQmlFuncNode"><p> <a name="submitEvent-method-1"></a><span class="name">submitEvent</span>(<span class="type">string</span> <i>eventName</i>, <span class="type">var</span> <i>data</i>)</p></td></tr> </table></div> </div><div class="qmldoc"><p>A utility method to create and submit an external event with the specified <i>eventName</i> as the name and <i>data</i> as the payload data (optional).</p> </div></div><!-- @@@submitEvent --> <br/> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 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>