Skip to content

Instantly share code, notes, and snippets.

@longlongh4
Created April 21, 2013 06:53
Show Gist options
  • Save longlongh4/5428731 to your computer and use it in GitHub Desktop.
Save longlongh4/5428731 to your computer and use it in GitHub Desktop.
The way to dynamically create animation group in Qt Quick
import QtQuick 2.0
Rectangle{
id: container
width: 800
height: 800
color: "black"
Rectangle{
id: rect
width: 50
height: 50
}
MouseArea{
anchors.fill: parent
onClicked: {
var childAnimationObject = Qt.createQmlObject("import QtQuick 2.1; NumberAnimation {id: animation; properties: \"x,y\"; duration: 1000; from:50; to:600; easing.type: Easing.Linear }",container)
childAnimationObject.target = rect
var paraComponent = Qt.createComponent("./ParallAnimation.qml");
var list = [];
list.push(childAnimationObject)
var paraAnimation = paraComponent.createObject(container,{"animations":list})
paraAnimation.start();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment