Easy way to "reuse" transitions from State Machine Framework
-
Hello,
I'm designing an application in which I make use of the SMF to help synchronize some of the widgets depending on user interaction.
The problem I have is that there are some situations in which, for a one same action taken by the user (in a particular case, a
KeyPress
event), I must transition to a particular state A if I'm in one of the {B,C,D,F} states (state names for example purpose).So, what I have to do is add, for each of the states in {B,C,D,F}, one
QEventTransition
of typeQEvent::KeyPress
, all of them having the same destination. But as the states claim ownership of transitions, I cannot new up a singleQEventTransition
and pass it to those states, forcing me to replicate the code several times.Is this really the way? Isn't there any way to reuse a transition, or even "clone" one to avoid so much retyping?
QEventTransition *t_maybeNewEntry = Q_NULLPTR; t_maybeNewEntry = new QEventTransition( mainWindow.ui->lineEditOutput, QEvent::KeyPress ); t_maybeNewEntry->setTargetState(s_hasEntry); //... t_maybeNewEntry = new QEventTransition( mainWindow.ui->lineEditOutput, QEvent::KeyPress ); t_maybeNewEntry->setTargetState(s_hasEntry); //... t_maybeNewEntry = new QEventTransition( mainWindow.ui->lineEditOutput, QEvent::KeyPress ); t_maybeNewEntry->setTargetState(s_hasEntry); //... ... ...
Thank you.