aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmltc/QmltcTests/signalConnections.qml
blob: d88e3920c3d2f2abc0c1bec3f8c16c7d595093a6 (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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtQml

QtObject {
    id: root

    property bool cycleEnabled: false
    property bool cycleFirst: false
    property bool cycleSecond: false

    property Timer enableTimer: Timer {
        running: root.cycleEnabled
        interval: 1
        onTriggered: {
            conn.enabled = !conn.enabled;
            root.cycleEnabled = false;
        }
    }

    property Timer firstTimer: Timer {
        id: firstTimer
        objectName: "first"
        running: root.cycleFirst
        interval: 1
        onTriggered: root.cycleFirst = false
    }

    property Timer secondTimer: Timer {
        objectName: "second"
        running: root.cycleSecond
        interval: 1
        onTriggered: conn.target = this;
        repeat: true
    }

    property Connections conn: Connections {
        id: conn
        target: firstTimer
        function onTriggered(m) {
            root.objectName = target.objectName
            root.cycleSecond = false;
        }
    }
}