Uploaded image for project: 'Qt for MCUs'
  1. Qt for MCUs
  2. QTMCU-158

shared condition for State works against what's stated in the documentation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • Qt for MCUs 2.5
    • Qt for MCUs 2.4
    • QML, QUL Team
    • None
    • Windows

    Description

      The repository to reproduce the issue : https://git.qt.io/mikio.hirai/statebug

      I'm using Windows11 with the Kit Qt for MCUs 2.4 - Desktop 32bpp(MSVC)

      In the State documentation(https://doc.qt.io/QtForMCUs-2.4/qml-qtquick-state.html), there's a sentence saying "If multiple states in a group have a when clause that evaluates to true at the same time, only the first matching state is applied. For example, in the following snippet, state1 is always selected rather than state2 when sharedCondition becomes true." with a code snippet :

      Item {
          states: [
              State { name: "state1"; when: sharedCondition },
              State { name: "state2"; when: sharedCondition }
          ]
          // ...
      } 

      I tried it myself with the qml file below:

      import QtQuick 2.0
      Rectangle {
          id: root
          width: 1000
          height: 1000
          Image {
              id: image
              source: "assets/download.jpg"
              MouseArea {
                  id: mousearea
                  anchors.fill: parent
              }
              transform: Rotation {
                  id: rotation
                  origin.x: image.width/2
                  origin.y: image.height/2
                  angle: 0
              }
          }
          states: [
              State {
                  name: "pressed"
                  when: mousearea.pressed // same when as "extended"
                  PropertyChanges {
                      target: rotation
                      angle: 180
                  }
              },
              State {
                  name: "extended"
                  extend: "pressed"
                  when: mousearea.pressed // same when as "pressed"   
                  PropertyChanges {
                      target: image
                      x: 500
                      y: 500
                  }
              }
          ]
          transitions: [
              Transition {
                  RotationAnimation {
                      direction: RotationAnimation.Clockwise
                      duration: 10000
                  }
              },
              Transition {
                  NumberAnimation {
                      properties: "x,y"
                      duration: 10000
                      easing.type: Easing.InOutQuad
                  }
              }
          ]
      } 

      Here, I used the same condition "mousearea.pressed" for "when" of both "pressed" state and "extended" state. 
      According to the documentation, when the "pressed" turned true in "mousearea," only the transition to "pressed," the first one, should be triggered, like in the attached "expected_bahavior.gif."
      However, when the "mousearea" is clicked, it seems that the behavior of the app shows it transitioned to "extended" instead, like in the attached "actual_behavior.gif."
       
       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kwkim Kwangsub Kim
            mikio_hirai Mikio Hirai
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes