Results 1 to 8 of 8

Thread: QState

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QState

    Did you try simply grouping states?

    Something alone the lines of:

    Qt Code:
    1. QState *masterState = new QState;
    2. QState *s1 = new QState(masterState);
    3. QState *s2 = new QState(masterState);
    4. QState *s3 = new QState(masterState);
    5. QState *s4 = new QState(masterState);
    6. masterState->setInitialState(s1);
    7. machine.addState(masterState);
    8. masterState->addTransition(signalEmitter, SIGNAL(received_1()), s1);
    9. masterState->addTransition(signalEmitter, SIGNAL(received_2()), s2);
    10. masterState->addTransition(signalEmitter, SIGNAL(received_3()), s3);
    11. masterState->addTransition(signalEmitter, SIGNAL(received_4()), s4);
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Oct 2011
    Posts
    51
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default Re: QState

    Wysota, thanks for answer, but unfortunately, I didn't understand you or your state machine is a "one way ticket" machine

    Qt Code:
    1. QState *masterState = new QState;
    2. QState *s1 = new QState(masterState);
    3. QState *s2 = new QState(masterState);
    4. QState *s3 = new QState(masterState);
    5. QState *s4 = new QState(masterState);
    6. masterState->setInitialState(s1);
    7. machine.addState(masterState);
    8. masterState->addTransition(signalEmitter, SIGNAL(received_1()), s1);
    9. masterState->addTransition(signalEmitter, SIGNAL(received_2()), s2);
    10. masterState->addTransition(signalEmitter, SIGNAL(received_3()), s3);
    11. masterState->addTransition(signalEmitter, SIGNAL(received_4()), s4);
    To copy to clipboard, switch view to plain text mode 

    You got only one way transitions, when you go to state s1, you don't have any transition that will let you to go back from it... Or I'd simply not understand you. Please came back with a more extensive example

    anda_skoa for this example I didn't need this kind of functionality, but I'll probably need this in the future, thanks for answer

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QState

    Did you try my code? The idea is that all the child states inherit transitions from the parent state so each of the four transitions defined in the parent state should work in any of the child states. I haven't tested it but it should work, if I understood the docs correctly.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Oct 2011
    Posts
    51
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default Re: QState

    I tried to get it working, but unfortunately I get stuck in initial child state

Similar Threads

  1. How to know the signal which caused a qstate transition
    By ClintEastwood in forum Qt Programming
    Replies: 6
    Last Post: 24th April 2013, 16:27
  2. QState machine using multiple QThreads
    By PeterWurmsdobler in forum Qt Programming
    Replies: 0
    Last Post: 14th May 2012, 11:55
  3. Perform a cyclic task in a QState
    By schall_l in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2010, 00:18
  4. Replies: 4
    Last Post: 25th March 2010, 11:32
  5. rotate in QState
    By estel in forum Qt Programming
    Replies: 0
    Last Post: 21st October 2009, 13:39

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.