[Qt-interest] Qt State machine framework

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Fri Mar 12 14:04:04 CET 2010


I had one more requirement, which I can't see a clean way to implement...

Say my FSM has 4 states: s1, s2, s3 and s4.

s4 can be entered from either s1, s2 or s3.

When in s4, on an event, I need to go back to the state from which I
had entered s4.

So the transition from s4 has to take into account from which state it
was entered so that it can go back to it. I can store the state using
the onExit() callback....but how do I make it go to the required
state. I can't use the setTarget() api since this has to be determined
while the FSM is running and not before when i'm setting up the
transitions.

Any thoughts?

Thanks,
-mandeep


On Fri, Mar 12, 2010 at 11:03 AM,  <noam.rosenthal at nokia.com> wrote:
> Hi Mandeep
> Actually both things are supported!
>
> 1. http://doc.trolltech.com/4.6/qabstracttransition.html#triggered: A signal that gets emitted when a transition is triggered. You can then query the tranistion's source/target properties.
> 2. http://doc.trolltech.com/4.6/qstatemachine.html#configuration: QStateMachine::configuration(), returns a set of current states.
>
> Hope this answers your question,

>
> Regards
> No'am
>
>>-----Original Message-----
>>From: qt-interest-bounces at trolltech.com
>>[mailto:qt-interest-bounces at trolltech.com] On Behalf Of ext
>>Mandeep Sandhu
>>Sent: Friday, March 12, 2010 2:20 PM
>>To: qt-interest at trolltech.com
>>Subject: [Qt-interest] Qt State machine framework
>>
>>Hi All,
>>
>>I'm planning to implement a FSM for one of my apps using the
>>Qt State machine framework. I have some requirements which
>>somehow are not there in this frame work by default (maybe I'm
>>missing something).
>>They are:
>>
>>* I need to emit a signal whenever the FSM transitions from 1
>>state to another. The signal emits the old state and the new state
>>* I need to provide an API to a caller to let it know what the
>>current state the FSM is in.
>>
>>For the 1st requirement I could not find an existing API's
>>which can do that (only started, stopped, finished signals are
>>emitted by the qtstatemachine class).
>>
>>I can think of many ways to do it, eg: create my own
>>transition and emit a signal in it's onTransition() method,
>>create my own state (subclassing the QtAbstractState and emit
>>a signal in it's onEntry method...though I won't have the
>>previous state then...)
>>
>>For the second part I need to keep updating some member of my
>>class to keep track of the current state (lame).
>>
>>Any suggestions on better approaches (if any)?
>>
>>Thanks,
>>-mandeep
>>_______________________________________________
>>Qt-interest mailing list
>>Qt-interest at trolltech.com
>>http://lists.trolltech.com/mailman/listinfo/qt-interest
>>



More information about the Qt-interest-old mailing list