Results 1 to 3 of 3

Thread: How to get the current state of QStateMachine

  1. #1
    Join Date
    May 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default How to get the current state of QStateMachine

    Hello. If I have for example three states s1, s2 and s3. How do I get the current state of the state machine.

    while(stateMachine->activeState() == s2)
    {
    //do something
    }

    Thanks.

  2. #2
    Join Date
    Mar 2009
    Location
    Belchatow, Poland
    Posts
    38
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: How to get the current state of QStateMachine

    I never used QStateMachine, but the docs say that every state emits entered() signal, you could create slots for every signal and have a variable that stores the current signal. Or even connect them all to one slot and use QObject::sender().

  3. #3
    Join Date
    Aug 2008
    Posts
    45
    Thanks
    1
    Thanked 6 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to get the current state of QStateMachine

    QStateMachine::configuration() gives you the current states.
    Qt Code:
    1. while(stateMachine->configuration().contains(s2))
    2. {
    3. //do something
    4. }
    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, 16:14
  2. State Machine returning to previous state
    By akiross in forum Qt Programming
    Replies: 2
    Last Post: 10th May 2011, 01:39
  3. Replies: 0
    Last Post: 19th December 2010, 17:03
  4. Replies: 5
    Last Post: 7th October 2010, 21:47
  5. Replies: 1
    Last Post: 7th August 2010, 23: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.