summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative/dynamicObjects.qml
blob: dd55d78f52c63fdaf13639e445ed21b7d4e67a0d (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
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();
        object.parent = rootItem;
    } 

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