1
2
3
4
5
6
7
8
9
10
11
使用了自定义的events 和 transitions
是并行状态,可以各自独立地进行转换。
The pinger state will post the first ping event upon entry; the ponger state will respond by posting a pong event; this will cause the pinger state to post a new ping event;
PingTransition class defines a transition that is triggered by PingEvent
PongTransition class defines a transition that is triggered by PongEvent,不过代码好像写错了
pinger->addTransition(new PongTransition);//转换是无目标的,当触发这样的转换时,源状态不会退出并重新进入,仅调用转换的 onTransition() 函数
Qt官方示例解析系列11:状态机Ping Pong States
本文由作者按照 CC BY 4.0 进行授权