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. Live observation of state machines in a Qt application
QtWS25 Last Chance

Live observation of state machines in a Qt application

Scheduled Pinned Locked Moved General and Desktop
dsmstatemachineqevent
4 Posts 2 Posters 1.8k 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.
  • C Offline
    C Offline
    Christopher
    wrote on last edited by Christopher
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • C Offline
        C Offline
        Christopher
        wrote on last edited by
        #3

        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
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          0

          • Login

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