Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
"entered" signal in Qstate is NOT called at fist
yustao last edited by
I encountered one strange problem on QState. Firstly, please allow me to describe our current code structure . We have one QTimer to call one function named “OnTickTimer” each 500 ms. And the code in “OnTickTimer” is like below code snippet.
switch (m_currentState) //I made simplification here – INIT, IDLE and RUN are all QState objects.
Supposing we use the “entered()” signal during state transition as below line:
QOjbect::connect(RUN, entered(), this, OnRun());
In most cases, the slot “OnRun” was called before “func3()”, which was what we expected. But unfortunately, that was not true all the time – sometimes “func3()” could also run before “OnRun()”.
Can you explain the use case of that architecture ? You can't expect a timer and an asynchronous system like a state machine to always have the same timed behavior.