• 3852阅读
  • 2回复

[提问]使用Qt的状态机以下功能该如何实现?高手请进! [复制链接]

上一主题 下一主题
离线bingyifeng
 

只看楼主 倒序阅读 楼主  发表于: 2014-03-19
各位高手,问题如下:
例如,一个QStateMachine,三个工作状态StateA,StateB,StateC
三个状态之间的迁移 靠CustomEvent驱动
三个状态中,具体需要处理的事务也得靠CustomEvent驱动

问题是 :
       如果我使用QStateMachine 的PostEvent 的话,就只能实现状态迁移,同时 State和QStateMachine的 event 函数收不到customEvent。
       处理事务的CustomEvent我该如何传递给具体的State呢?
       或者还有什么其他方法实现上面的需求么?
本帖提到的人: @XChinux
<span style="color:blue ">淘宝,绿石斋</span> <a href="http://shop33295817.taobao.com“> <span style="color:blue ">各种水晶饰品,手链,项链 </span></a>
离线bingyifeng

只看该作者 1楼 发表于: 2014-03-19
哦,貌似解决了。
<span style="color:blue ">淘宝,绿石斋</span> <a href="http://shop33295817.taobao.com“> <span style="color:blue ">各种水晶饰品,手链,项链 </span></a>
离线bingyifeng

只看该作者 2楼 发表于: 2014-03-20
结贴:
用这个方法实现
Targetless Transitions

A transition need not have a target state. A transition without a target can be triggered the same way as any other transition; the difference is that when a targetless transition is triggered, it doesn't cause any state changes. This allows you to react to a signal or event when your machine is in a certain state, without having to leave that state
<span style="color:blue ">淘宝,绿石斋</span> <a href="http://shop33295817.taobao.com“> <span style="color:blue ">各种水晶饰品,手链,项链 </span></a>
快速回复
限100 字节
 
上一个 下一个