[SOLVED] Can a QHistoryState remember the children state of a sibiling state?

Table of Contents

Issue

In the State Machine Framework page on the QState machine, it talks about how QHistoryState works. A QHistoryState is instantiated as the child of another state, like in the example on the doc page:

enter image description here

However, while this QHistoryState in the example will remember which s1x state you were at before interruption, I wanted to know how far down it can remember transitions. For example, say state s13 had it’s own subsidiary state machine like so:

enter image description here

In this expanded example, QHistoryState is not the child of s13, only s1. However, let’s say we were at state s132 and then the interruptButton is clicked, thus temporarily transitioning to s3. When we go back to s13….which child state of s13 will we be in? s131, s132, or s133?

Therefore, my question is:

Question

Can the QHistoryState in the example I set up remember which s13x state was active upon transitioning back to the parent s1 state from s3?

Solution

Look at the historyType member. As an aside, you might want to re-examine your design. State machines aren’t intended to rely on prior states for execution.

Answered By – mzimmers

Answer Checked By – Marie Seifert (BugsFixing Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *