Results 1 to 2 of 2

Thread: QStateMachine set state

  1. #1
    Join Date
    Dec 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QStateMachine set state

    Hi,
    I have a QStateMachine and I need to go directly at one QState without SIGNAL.
    I need a function like GoToState(QAbstractState*).
    Suggestions?
    Thanks
    Teo

  2. #2
    Join Date
    Oct 2011
    Location
    Australia
    Posts
    29
    Thanks
    2
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QStateMachine set state

    Its pretty clear from the documentation that you can't (unfortunately? not sure), unless you extend QState yourself. Cant see why you would need to, except for convenience sake (agreed? not sure either ). The way suggested is to put all states in a parent state and define a transition on the parent, then post an Event/Signal to the machine:

    Qt Code:
    1. QStateMachine * m = new QStateMachine();
    2. QState * operational = new QState(m);
    3. QState * error = new QState(m);
    4. QState * init = new QState(operational);
    5. QState * a = new QState(operational);
    6. QState * b = new QState(operational);
    7. QState * c = new QState(operational);
    8. //... more states ...
    9. m->setInitialState(operational);
    10. operational->setInitialState(init);
    11.  
    12. operational->addTransition(this,SIGNAL(error()),error);
    13. error->addTranistion(this,SIGNAL(fixedError()),operational);
    14. //... more transitions ...
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Finding the current state of a QStateMachine
    By pherthyl in forum Qt Programming
    Replies: 3
    Last Post: 18th July 2012, 15:14
  2. QStateMachine state change problem
    By QTie in forum Qt Programming
    Replies: 0
    Last Post: 6th June 2011, 09:09
  3. How to get the current state of QStateMachine
    By QTie in forum Qt Programming
    Replies: 2
    Last Post: 1st June 2011, 13:23
  4. Replies: 5
    Last Post: 7th October 2010, 20:47
  5. Replies: 1
    Last Post: 7th August 2010, 22:38

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.