Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. "entered" signal in Qstate is NOT called at fist

"entered" signal in Qstate is NOT called at fist

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 609 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yustao
    wrote on last edited by
    #1

    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.

    void onTickTimer()
    {
    switch (m_currentState) //I made simplification here – INIT, IDLE and RUN are all QState objects.
    {
    case INIT:
    func1();
    break;
    case IDLE:
    func2();
    break;
    case RUN:
    func3();
    break;
    default:
    break;
    };
    }

    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()”.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved