Skip to content
  • 0 Votes
    4 Posts
    363 Views
    jeremy_kJ

    This looks like a bug. changes can either be a list of inline Change elements, or a list accessed by id or a property. The error message changes depending on the order. With an id first, it complains about missing a , for inline elements. With an inline element first, it complains about a missing { for ids.

    import QtQuick 2.15 import QtQuick.Window 2.15 Window { MouseArea { anchors.fill: parent; onClicked: text.nextState() } Text { id: text anchors.centerIn: parent text: "click to change" PropertyChanges { id: a; target: text; color: 'red' } PropertyChanges { id: b; target: text; text: "State B" } state: "a" states: [ State { name: "a" changes: [ PropertyChanges { target: text; text: "State A" }, PropertyChanges { target: text; color: "blue" } ] }, State { name: "b" changes: [ a, b ] }, State { name: "c" // The next line causes a syntax error changes: [ PropertyChanges{ target: text; text: "State C" }, a ] } ] function nextState() { for (var i = 0; i < states.length; i++) { if (state === states[i].name) { state = states[(i + 1) % states.length].name; return; } } } } }

    That said, I don't think I have ever seen a code base attempt to reuse a PropertyChange in this way. Organizing into base states that contain the common changes, and extended states that customize is usually the way it's done. With a *Change inline in a State, there no need to even mention changes

  • 0 Votes
    2 Posts
    1k Views
    p3c0P

    Hi @Kofr
    Check out this example especially this file. There you can use findChild instead to find Converter and then get the data in the same way.

  • 0 Votes
    10 Posts
    4k Views
    ?

    My point is simply that blind adherence a principle or method can actually be worse than fully understanding the needs and goals of what you are trying to do.

    Amen.