Details
-
Bug
-
Resolution: Duplicate
-
P2: Important
-
Qt for MCUs 2.6
-
None
Description
I checked these pages but couldn't find this limiation, so let me create a JIRA.
- https://doc.qt.io/QtForMCUs-2.5/qml-qtquick-state.html#name-prop
- https://doc.qt.io/QtForMCUs-2.2/default-state-limitations.html
- https://doc.qt.io/QtForMCUs-2.2/qtquick-statesanimations-states.html
- https://doc.qt.io/QtForMCUs-2.5/qtul-known-issues.html
As far as I know, there are two ways to implement state transitions in QML; setting when property in State QML type or directly assigning the State's name property value to state property of Item-related QML types.
I tried mixing both approaches in one app and it seems to be not working.
If this is technically impossible, it would be helpful to add this as one of the limitations.
The sample project is attached to this ticket but here's the code to get the idea;
// Define_and_Transition_States.qml import QtQuickRectangle { id: root color: "black" MouseArea { id: mouseArea anchors.fill: parent onPositionChanged: { root.state = "blueScreen" // <-- using "assignment" } onReleased: { root.state = "" //<-- using "assignment" } onPressed: { console.log("pressed") } } states: [ State { name: "redScreen" when: mouseArea.pressed // <-- using "when" PropertyChanges { target: root; color: "red" } }, State { name: "blueScreen" PropertyChanges { target: root; color: "blue" } } ] }
When you launch the app and press the screen, the screen color changes to red, then by keep pressing and moving the cursor, the color changes to blue, finally, releasing the mosue cursor gets the color back to black.
When you press the screen again, the color won't change to red, even though you see the debug message "pressed" in the Application Ouptput. You can keep pressing and moving the cursor to confirm the "assignment" approach still works.