Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. PropertyAction for AnchorChanges
Forum Updated to NodeBB v4.3 + New Features

PropertyAction for AnchorChanges

Scheduled Pinned Locked Moved QML and Qt Quick
qmlstates
2 Posts 1 Posters 996 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.
  • A Offline
    A Offline
    AlbertoJR
    wrote on last edited by
    #1

    Hi all,

    I have an Item with some states, and some PropertyChanges. Also, i've defined a transition between states, with a ParallelAnimation.
    Inside of the ParallelAnimation, i've put some PropertyAnimation and some PropertyActions, because i want some property values to be changed at the beginning of the transition, without any animation.

    My problem is about an AnchorChange element in the state. I want the anchor to be changed also at the beginning of the transition, without animation. I tried to use a PropertyAction, but it doesn't work with the anchor.

    I would like to know if PropertyAction can be used with anchors, because i cannot find any information about that in the documentation. It seems that the PropertyAction elment can only be used with properties configured in the PropertyChanges elements.

    Many thanks in advance

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AlbertoJR
      wrote on last edited by
      #2

      Hi again:

      I've prepared a testing qml to show the issue:

      Window {
          visible: true;width: 360;height: 360
      
          MouseArea{
              anchors.fill: parent
              onClicked: container.state = (container.state=="estado1"?"estado2":"estado1")
          }
      
          Rectangle {
              id: container
              anchors.fill: parent
              color: "red"
              state: "estado1"
              onStateChanged:console.log("state -> "+state)
      
              Rectangle {
                  id: prueba
                  anchors.left: parent.left
                  height: 100
                  color: "blue"
                  onWidthChanged:console.log("width -> "+width)
                  onHeightChanged:console.log("height -> "+height)
                  onOpacityChanged:console.log("opacity -> "+opacity)
                  onYChanged: console.log("coordY -> "+y)
      
              }
              states: [
                  State {
                      name: "estado1"
                      PropertyChanges {
                          target: prueba
                          width: 300
                          opacity: 1
                      }
                      AnchorChanges {
                          target: prueba
                          anchors.bottom: container.bottom
                      }
                  },
                  State {
                      name: "estado2"
                      PropertyChanges {
                          target: prueba
                          width: 50
                          opacity: 0.5
                      }
                      AnchorChanges {
                          target: prueba
                          anchors.top: container.top
                      }
                  }
              ]
              transitions:[
                  Transition {
                      ParallelAnimation {
                          PropertyAnimation {
                              target: prueba
                              properties: "width"
                              duration: 3000
                          }
                          PropertyAction {
                              target: prueba
                              property: "opacity"
                          }
                          /*PropertyAction {
                              target: prueba
                              property: "anchors.top" //doesn't work
                              //property: "anchors" //doesn't work neither
                          }*/
                          AnchorAnimation {
                              //works, but doesn't seem to be the most
                              //elegant solution to the problem
                              duration: 0
                          }
                      }
                  }
              ]
          }
      }
      

      If you run this example as is, you can see that the anchor change is performed at the beginning of the transition, because of the animation with duration=0. I think this is not very correct, since you really don't need an animation for that.

      For PropertyChanges, you can use the PropertyAction, as can be seen for the opacity change in the example. But, the PropertyAction doesn't work with the AnchorChange. I don't know if this is because of the sintax, or really PropertyAction cannot be used in this situation. I would like to know what is the best and more correct approach to do that.

      Thanks for your patience

      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