Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Live observation of state machines in a Qt application

    General and Desktop
    dsm statemachine qevent
    2
    4
    1524
    Loading More Posts
    • 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.
    • C
      Christopher last edited by Christopher

      Hello everybody,

      I'm trying to extract all the state machines of my application which are defined as DSM in QML.
      For documentation purposes I want to visualize the state machines and active states while the application is running (maybe with Graphviz like Gamma Ray does it).

      My first attempt was to install a eventFilter into my QGuiApplication and listen to all QChildEvents to recognize states added to a statemachine. Then I would build the state machines on my own and visualize them.

      bool FilterObject::eventFilter(QObject *object, QEvent *event)
      {
          if (event->type() == QEvent::ChildAdded) {
              QChildEvent *childAddedEvent = static_cast<QChildEvent*>(event);
      
              childAddedEvent->child()->installEventFilter(new FilterObject());
      
              qDebug() << "added" << childAddedEvent->child()->metaObject()->className() << "to" << object->metaObject()->className();
         
          }
      }
      

      Unfortunately I get mostly.

      • added QObject to ...
      • added QObject to ...
      • added QObject to ...

      So I can't really determine the if a QState is added to the state machine.

      Inherit QStatemachine, QState, ... and implement everything I need to access the state machines from outside could be an alternative way, but maybe there is an easier method.

      Do have any idea how I can observe my state machines without an external tool and maybe without the knowledge about the state machines.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        Are you sure a tool like KDAB's Gamma Ray is out of question for your job ?

        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 Reply Quote 0
        • C
          Christopher last edited by

          Hi,

          Yes, GammaRay might solve the problem, but I want to automate the process as much as possible.
          Example: I press a button in my application -> a screenshot of the application and all state machines are saved.

          With GammaRay I have to save the images of the state machines by hand (not .scxml or at least .dot)

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Then you should either check the code where they do that and integrated it to your project or add the image saving feature to GammaRay

            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 Reply Quote 0
            • First post
              Last post