summaryrefslogtreecommitdiffstats
path: root/examples/declarative/dynamic/dynamic.qml
blob: 3e0c12ec8b7fd1eb84967d3280a0a51eb84aaf6d (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
Rect { id: page; width: 800; height: 800; color:"black"
    Script { source: "dynamic.js" }
    property bool extendStars: false;
    Item { id: targetItem; x: 100; y: 100; }
    Item { id: targetItem2; x: 0; y: 300; }
    Rect { width: 100; height: 100; color: "green"; id: rect
        MouseRegion { anchors.fill:parent; onClicked: {a = createWithComponent();}}
    }
    Rect { width: 100; height: 100; color: "red"; id: rect2; y:100;
        MouseRegion { anchors.fill:parent; onClicked: {destroyDynamicObject();}}
    }
    Rect { width: 100; height: 100; color: "blue"; id: rect3; y:200;
        MouseRegion { anchors.fill:parent; onClicked: 
            { 
                if(fourthBox == null) {
                    a = createWithEvalQml();
                    if(a!=null) {
                        a.parent = targetItem2;
                        fourthBox = a;
                        extendStars = true;
                    }
                } else {
                    fourthBox.destroy();
                    fourthBox = null;
                    extendStars = false;
                }
            }
        }
    }
    Particles { x:0; y:0; count:20; lifeSpan:500; width:100; height: if(extendStars){400;}else{300;} source:"star.png"}
}