Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Using QScxmlStateMachine data model QML
Forum Updated to NodeBB v4.3 + New Features

Using QScxmlStateMachine data model QML

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
2 Posts 2 Posters 412 Views 1 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.
  • D Offline
    D Offline
    d_h_mcinnes
    wrote on last edited by d_h_mcinnes
    #1

    Hi

    I found an example of using Scxml in QML here: https://doc.qt.io/qt-5/qtscxml-instantiating-state-machines.html

    The example is great, it lets you do the following:

    import MyStateMachine 1.0
    
    MyStateMachine {
        id: stateMachine
    }
    
    Light {
        id: greenLight
        color: "green"
        visible: stateMachine.green // this is what I want to do, toggle visibility based on whether I am in a certain state
    }
    
    

    ... but it only seems to work if you instantiate your state machine in QML.

    In my case, I have instantiated the state machine in C++, and am having trouble making the state machine properties visible to my QML code. The generated C++ code contains a Q_PROPERTY(bool some_state), but does not include getters, setters, or 'changed' signals for each of the states. So, when some event happens, the C++ state machine enters the correct state, but the QML code doesn't receive any signal, and my green light never turns on.

    Is there some way I can make my C++ Qscxml state machine transitions visible in QML land?

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

      Hi,

      Please show the code you use. Otherwise it's impossible to start helping you.

      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