handle
handle

Reputation: 6329

QStateMachine immediate transition from dummy state

In order to set an object property depending on a transition I need two intermediate states that immediately transition further:

   A       initial state
 Ta Tb     different transitions
 Aa  Ab    (these are only used to set an objects property depending on transition)
 TB TB     both should immediately "transit"
   B       objects property used via entered()/exited() signals

(Alternatively, B probably could be duplicated to set each respective property directly.)

Could a state's entered() signal be used as its own transition source?

Upvotes: 2

Views: 1465

Answers (2)

Simply add an unconditional transition to the state:

TB->addTransition(B);

This is idiomatic and also cheaper than using a QSignalTransition coupled to the entered() signal.

Ref: http://doc.qt.io/qt-5/statemachine-api.html#targetless-transitions

Upvotes: 3

handle
handle

Reputation: 6329

Yes, the QState's entered() signal can be used as transition source.

Upvotes: 0

Related Questions