summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative/dynamicObjects.qml
blob: 6a8c927ddc23e11a72f1bd59353916a8cc75a494 (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
import Qt 4.7

//![0]
Rectangle {
    id: rootItem
    width: 300
    height: 300

    Component {
        id: rectComponent

        Rectangle {
            id: rect
            width: 40; height: 40;
            color: "red"

            NumberAnimation on opacity { from: 1; to: 0; duration: 1000 }

            Component.onCompleted: rect.destroy(1000);
        }
    }

    function createRectangle() {
        var object = rectComponent.createObject(rootItem);
    } 

    Component.onCompleted: createRectangle()
}
//![0]