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. Problems with QStateMachine?
Forum Updated to NodeBB v4.3 + New Features

Problems with QStateMachine?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.2k Views 2 Watching
  • 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.
  • X Offline
    X Offline
    xianerzaiwai
    wrote on last edited by
    #1

    My application has more than one instances of a Widgets UI at runtime. Every instance creates its own statemachine during initialization.
    MyStateMachine * fsm = new MyStateMachine();
    During development, I just use QTest::qWait(1000) simulating an action at every state.

    However the statemachine doesn't run smoothly:

    1. If I click the graphic interface among the instances every fast. I get the following error:
      QStateMachine::postEvent: cannot post event when the state machine is not running
      As a consequence, that statemachine hangs. It's interesting, that it's happening always shortly after the start of the statemachine.

    My guess: the instance losts perhaps its focus, as a result, the defined connects between signal and slots don't work any more. How could I improve it? Any experience from you?

    1. Some statemachines get suddenly stuck, wait more than specified 1 second in ist progress.
      Maybe the thread for QTest::qWait doesn't work properly. Do you have any better method make a unblocked delay for a couple of seconds?

    Many thanks in advance for your insights.

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

      Hi and welcome to devnet,

      QTest::qWait is for testing purpose only so you should not use it in production code. If you need a delay between two state; did you try a QTimer + QSignalTransition combo ?

      Otherwise, you'll have to give more details about your state machine

      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