QStateMachineを作成しましたが、状態の遷移を引き起こしたイベントを取得する必要があります。私のスロットに入る機会はありませんEnterStateInit()
この呼び出しの原因となったシグナル。ここに私のサンプルコード:QStateMachineは状態遷移を引き起こすイベントを取得します
CreateStateMachine()
{
QState *Init = new QState();
QState *CheckPrecondition = new QState();
QState *DoWork = new QState();
Init->addTransition(this, SIGNAL(EventStart()), CheckPrecondition);
CheckPrecondition->addTransition(this, SIGNAL(EventSuccesfulCondition()), DoWork);
CheckPrecondition->addTransition(this, SIGNAL(EventNotSuccesfulCondition()), Init);
DoWork->addTransition(this, SIGNAL(EventWorkDone()), Init);
DoWork->addTransition(this, SIGNAL(EventError()), Init);
connect(Init, SIGNAL(entered()), this, SLOT(EnterStateInit()));
connect(CheckPrecondition, SIGNAL(entered()), this, SLOT(CheckPrecondition()));
connect(DoWork, SIGNAL(entered()), this, SLOT(DoWork()));
connect(Init, SIGNAL(exited()), this, SLOT(LeaveStateInit()));
connect(CheckPrecondition, SIGNAL(exited()), this, SLOT(LeaveStateCheckPrecondition()));
connect(DoWork, SIGNAL(exited()), this, SLOT(LeaveDoWork()));
mModuleStateMachine.addState(Init);
mModuleStateMachine.addState(CheckPrecondition);
mModuleStateMachine.addState(DoWork);
mModuleStateMachine.start();
}
EnterStateInit()
{
/* Get Event which caused this SLOT to react */
SetStatus();
}
正確に何をしようとしていますか? – thuga
@thuga私は書面によるマニュアルを交換するためのツールに取り組んでいます。このツールは、手動でいくつかの手順を自動的に行い、その他は手動で行う必要があります。 State Initに入っている場合(1つのステップが完了している)、このステップのステータスを設定したいと思います。何かが間違っていた場合(前提条件が成立せず、キャンセルがクリックされた場合)、状態Initに入ってステータスを設定します。私が状態Initに入ると、何かが以前に間違っていたかどうかを知る必要があります。したがって、どの信号がSLOT EnterStateInit()に反応してステップのステータスを設定させたかを調べる機会を探しています。 – Lehtim
なぜ、エラーの新しい状態を作成しないのですか?結局のところ、それは別の状態です。 – thuga