ListModelは可動要素の機能を提供し、GridView(グリッドだけでなく)と共に使用することができます。あなたは、デリゲートにアニメーションを追加したい場合は
GridView {
id: grid
anchors.fill: parent
cellWidth: 32
cellHeight: 32
property bool loaded: false;
model : ModelInheritingListModel {
}
delegate: MyDelegate {
}
onSwap: {
var min = Math.min(slot1, slot2);
var max = Math.max(slot1, slot2);
grid.model.move(min, max, 1);
grid.model.move(max-1, min, 1);
}
}
そして、スワップとき:
Item {
id: main
width: grid.cellWidth
height: grid.cellHeight
Image {
id: img
x: main.x
y: main.y
/* In order to use animations, we can't use the main level component as
it technically is the same item, so we need to animate the image.
So we set the image's position relative to the parent instead, so
we can animate its coordinates properly */
parent: grid
Behavior on x { NumberAnimation { duration: 400; easing.type: Easing.InOutCubic}}
Behavior on y { NumberAnimation { duration: 400; easing.type: Easing.InOutCubic}}
source: imagesource
width: 32
height: 32
}
}
お知らせあなたが親を変更して、使用する必要がありトリック...
くそーQML!