[Qt-interest] State Machine implementation

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Thu Feb 3 06:04:34 CET 2011


>
>
> But I don't think I can realize that using signals ? How can you pass the
> params from the signal to another state ? Do I need some custom events
> instead ?
>

I think you should be able to use QSignalTransition &
SignalEvent::arguments() for your need. Eg: if your app selector widget
emits a signal "appSelected(int)", you can use QSignalTransition to
transition to your "app" state. Here, in enterState(QEvent*), you can access
the SignalEvent and extract the app number that was emitted by your widget
(using SignalEvent::arguments()).
No postEvent() is needed here as thats taken care of by QSignalTransition.

Another way to achieve this is to have your own custom event which can
encapsulate your arguments. Manually post this event (in a slot handling the
"appSelected(int)" signal). When the SM transitions to the new state, this
event will be provided in enterState() callback. You can extract your arg
from it then and use it however you like.
In this case however, you will have to manually do a postEvent().

HTH,
-mandeep



> That means that the display widget will be aware of the SM and use
> postEvent ?
>
> thanks again.
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110203/06de9264/attachment.html 


More information about the Qt-interest-old mailing list