aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/threading/threadedlistmodel/timedisplay.qml
blob: 9c14fb1d11eb1dbd68c1ddbd6e7484e9807dde4e (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) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick

Rectangle {
    color: "white"
    width: 200
    height: 300

    ListView {
        anchors.fill: parent
        model: listModel
        delegate: Component {
            Text {
                required property string time
                text: time
            }
        }

        ListModel { id: listModel }

        WorkerScript {
            id: worker
            source: "dataloader.mjs"
        }

// ![0]
        Timer {
            id: timer
            interval: 2000; repeat: true
            running: true
            triggeredOnStart: true

            onTriggered: {
                var msg = {'action': 'appendCurrentTime', 'model': listModel};
                worker.sendMessage(msg);
            }
        }
// ![0]
    }
}