aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickgridview/data/qtbug86255.qml
blob: 20688b1967286c5e18df504c7168551bf72c1aa2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import QtQuick 2.15

Item {
    width: 240
    height: 320

    GridView {
        id: grid
        objectName: "view"
        anchors.fill: parent
        cellWidth: 64
        cellHeight: 64
        model: ListModel {
            id: listModel

            Component.onCompleted: reload()

            function reload() {
                clear();
                for (let i = 0; i < 1000; i++) {
                    let magic = Math.random();
                    append( { magic } );
                }
            }
        }
        clip: true
        delegate: Item {
            id: d
            property string val: magic
            Loader {
                property alias value: d.val
                asynchronous: true
                sourceComponent: cmp
            }
        }
    }

    Timer {
        running: true
        interval: 1000
        onTriggered: listModel.reload()
    }
    Timer {
        running: true
        interval: 500
        onTriggered: grid.flick(0, -4000)
    }

    Component {
        id: cmp
        Text {
            text: value
        }
    }
}