Qt SCXML Invoke Example (Static)#
Invokes a compiled nested state machine.
Invoke Example (Static) demonstrates how to use the <invoke>
element with generated nested state-machines, where the SCXML file is compiled to a C++ class. The <invoke>
element is used to create an instance of an external service.
Running the Example#
To run the example from Qt Creator, open the Welcome mode and select the example from Examples. For more information, visit Building and Running an Example.
Invoking the State Machine#
In statemachine.scxml, we specify a state machine with the name Directions of type http://www.w3.org/TR/scxml/ to invoke:
Compiling the State Machine#
We link against the Qt SCXML module by adding the following lines to the example’s build files.
invoke-static.pro*
when using qmake:#
We then specify the state machine to compile:
CMakeLists.txt*
when using cmake:#
We then specify the state machine to compile:
The statechart directives STATECHARTS or qt6_add_statecharts invoke the Qt SCXML Compiler, qscxmlc
, which is run automatically to generate statemachine.h and statemachine.cpp, which are then added appropriately as headers and sources for compilation.
Instantiating the State Machine#
We instantiate the generated Directions
class in the invoke-static.cpp file, as follows: