PDA

View Full Version : How to get the current state of QStateMachine



QTie
1st June 2011, 10:45
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.

arturo182
1st June 2011, 12:11
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().

joyer83
1st June 2011, 13:23
QStateMachine::configuration() gives you the current states.


while(stateMachine->configuration().contains(s2))
{
//do something
}