3

GridView のサイズが変更され、その要素が再配置されると、その要素のアニメーションが機能しないようです。

ここに簡単な例があります: http://pastebin.com/BgST6sCv
例 の正方形の 1 つをクリックすると、アニメーションが適切にトリガーされます。ただし、GridView が要素を再配置する必要があるようにウィンドウのサイズを変更すると、アニメーションはトリガーされません。

それを修正する方法はありますか?おそらくC++なしで?

編集:
現在、Qt 4.7.3 を含む Qt SDK 1.1 を使用しています。

4

1 に答える 1

3

このコードはそれを行います。基本的に、ダミーのデリゲートアイテムを作成してから、同じ幅、高さ、x、yの値を持つ別のアイテムをその中に作成する必要があります。内側のアイテムの親をグリッドビューに設定します。これがうまくアニメーション化するように変更されたコードです。

import QtQuick 1.0

Rectangle {
    id: mainRect
    width: 300; height: 400

    ListModel {
        id: appModel
        ListElement { modelcolor: "#FF0000"}
        ListElement { modelcolor: "#00FF00"}
        ListElement { modelcolor: "#0000FF"}
    }

    Component {
        id: appDelegate

        Item {
            id: main
            width: grid.cellWidth; height: grid.cellHeight
            Rectangle {
                id: item; parent: grid
                x: main.x; y: main.y
                width: main.width; height: main.height;
                color: modelcolor
                Behavior on x { NumberAnimation { duration: 400; easing.type: Easing.OutBack } }
                Behavior on y { NumberAnimation { duration: 400; easing.type: Easing.OutBack } }
            }
        }
    }

    GridView {
        id: grid
        anchors.fill: parent
        model: appModel
        delegate: appDelegate
        interactive: false
        MouseArea {
            anchors.fill: parent
            onClicked: {
                appModel.insert(1, { "modelcolor": "yellow" } )
            }
        }

    }
}
于 2011-05-29T11:49:12.847 に答える