Important: Please read the Qt Code of Conduct -

Add transition state machine

  • I implemented a three state machine and declared a function that change the current state of the machine: void changeState(s1); that contains the following command in order to change machine state:

    @s0->addTransition(s1) @

    because I don't have any sender and receiver.
    When I compile it no error appears, but when I run the application the following message appears:

    QObject::setParent: Cannot set parent, new parent is in a different thread

    Shall I necessarily connect the transition to a signal? If yes how can I do it?

    Thanks a lot for your help.


  • Hi Luca,

    The runtime error you show means that the new parent was created in a different thread than current one.

    Related to your code, this means that s0 was created in a Thread and the addTransition call is done in a different one.

    Could you post your code?

Log in to reply