2016-11-15 70 views
0

我想动画边距值动画变化QML,但我不能。动画不能正常工作qml动画边距变化

这是我的状态

State { 
    name: "up" 
    PropertyChanges { 
     target: drag_line 
     anchors.topMargin: 50 
    } 

与转型我想

​​

我也尝试了一些动漫,但它也没有工作。有什么办法,我是不是做错了什么

回答

2

的属性不是marginanchors.topMargin

这是我的工作例如:

ApplicationWindow { 
    visible: true 
    width: 500 
    height: 500 

    Rectangle { 
    width: 100 
    height: 100 
    anchors.centerIn: parent 
    color: "red" 

    Rectangle { 
     id: iRect 
     color: "blue" 
     width: 40 
     height: 40 
     anchors.top: parent.top 

     states: [State { 
     name: "up" 
     when: iMouseArea.pressed 
     PropertyChanges { 
      target: iRect 
      anchors.topMargin: 50 
     } 
     }] 

     transitions: [ 
     Transition { 
      to: "up" 
      NumberAnimation { properties:"anchors.topMargin"; easing.type: Easing.InOutQuad;duration: 300 }   
     } 
     ] 
    } 

    MouseArea{ 
     id: iMouseArea 
     anchors.fill: parent 
    } 
    } 
} 
+0

完全我的错!感谢指出.. –