aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/QtQml/qqmlincubator_incubateWhile.qml
blob: 803dec128311c0c4f1e114cca05ada36ed62e8c4 (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import QtQuick 2.0


Rectangle {
    id: root
    objectName: "theNicestRoot"
    width: 400; height: 400

    signal shouldInterrupt()
    property int loadedItems: 0
    property int itemsToCreate: 10

    Row {
        anchors.centerIn: parent
        spacing: 20

        Rectangle {
            id: initialRectangle
            width: 10; height: 10
            color: "red"
        }

        Repeater {
            model: itemsToCreate
            Loader {
                id: loader
                asynchronous: true
                source: "qqmlincubator_incubateWhile_component.qml"
                onLoaded: {
                    root.loadedItems += 1

                    // Interrupt incubation after half of the items are loaded.
                    if (root.loadedItems >= (itemsToCreate / 2)) {
                        root.shouldInterrupt()
                    }
                }
            }
        }
    }
}