I'm trying to start using the Qt State machine framework for more things, but one of the central problems I keep running into is that I need to find out what the current state is, and do the appropriate thing.

However, there does not seem to be any way to figure out what state a QStateMachine is currently in, which is completely perplexing to me, since this seems like such a basic thing.

For example, say I have an item on a scene. The first time someone clicks on it, we are in the "list view" state and the item is selected while everything else fades out. The second time it is clicked, I perform some action. So to figure out what I should do in the click handler, I have to check the state (are we in the "list view" state or the "selected" state?). Unfortunately I can't tell without having another variable that will keep track of current state. That seems a bit stupid, since the state machine should do that.

However, perhaps I'm looking at the problem wrong, and I haven't fully transitioned my thinking to a state-based approach.

All the examples in Qt for state machines seem to be so simple that they are essentially useless (like the stoplight example). Does anyone have a good example of a state machine being used for a more realistic application? Why can't I find out what state I am currently in?