QM  5.1.4
Model-Based Design Tool
Working with Statecharts

Adding a Statechart

In the Model Explorer right-click on the Class to which you want to add the state machine and select Add State Machine from the popup menu.

Adding a State Machine to a Class
The Add State Machine menu option is only available if a given class directly or indirectly inherits the QP class QHsm. Otherwise the option is "grayed-out".

Resizing a State Machine Diagram

As shown in the screen shot below, you can easily resize the Drawing Canvas of a State Diagram by dragging its right or bottom edges, or by dragging the resize handle in the bottom-right corner of the canvas. In each case the mouse cursor indicates the possible direction of resizing.

Resizing the Drawing Canvas

Statechart Property Sheet

Statechart items can be configured by the Statechart-Specific Property Sheet.

Statechart Property Sheet

The statechart-item property sheet contains the following properties:

Use "me->"

Checkbox that controls the state machine implementation style. When checked, the old use me-> pointer style is applied. If unchecked (recommended), the new no me-> pointer style is used. Please refer to the QP/C++ documentation of this feature.

The Use me-> checkbox is only relevant for models based on QP/C++ (qpcpp). For models based on QP/C or QP-nano, this checkbox is permanently checked and is "grayed-out" meaning that it cannot be unchecked.


Checkbox that turns on/off the automatic generation of the QS_FUN_DICTIONARY() macros for all states of a given statechart. The dictionary macros are generated in the top-most initial transition of the statechart. Below is an example of generated code with the QS_FUN_DICTIONARY() macros:

/*${SMs::Calc::SM} .........................................................*/
static QState Blinky_initial(Blinky * const me, void const * const par) {
/*.${AOs::Blinky::SM::initial} */
(void)par; /* unused parameter */
. . .
return Q_TRAN(&Blinky_off);


The documentation entry in the Statechart Property Sheet allows you to provide documentation to the statechart. The QM code generator parses the documentation entry and can generate comments for the top-most initial transition of this statechart.