aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/snippets/qml/qml-extending-types/signals/connectdynamic.qml
blob: 5e6469a44b890a9c550a288c1ebfb9169332165d (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
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
//![0]
Item {
    id: item
    width: 300; height: 100

    function myMethod() {
        console.log("Button was clicked!")
    }

    Row { id: row }

    Component.onCompleted: {
        var component = Qt.createComponent("Button.qml")
        for (var i=0; i<3; i++) {
            var button = component.createObject(row)
            button.border.width = 1
            button.buttonClicked.connect(myMethod)
        }
    }
}
//![0]