Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / tests / auto / declarative / qdeclarativecomponent / data / createObjectWithScript.qml
1 import QtQuick 1.0
2
3 Item{
4     id: root
5     property QtObject declarativerectangle : null
6     property QtObject declarativeitem : null
7
8     property QtObject bindingTestObject : null
9     property QtObject bindingThisTestObject : null
10
11     Component{
12         id: a
13         Rectangle {
14             property Rectangle innerRect: Rectangle { border.width: 20 }
15         }
16     }
17     Component{
18         id: b
19         Item{
20             property bool testBool: false
21             property int testInt: null
22             property QtObject testObject: null
23         }
24     }
25
26     // test passing in bindings
27     width: 100
28     Component {
29         id: c
30         Item {
31             property int testValue
32             width: 300
33         }
34     }
35
36     Component.onCompleted: {
37         root.declarativerectangle = a.createObject(root, {"x":17,"y":17, "color":"white", "border.width":3, "innerRect.border.width": 20});
38         root.declarativeitem = b.createObject(root, {"x":17,"y":17,"testBool":true,"testInt":17,"testObject":root});
39
40         root.bindingTestObject = c.createObject(root, {'testValue': (function(){return width * 3}) })  // use root.width
41         root.bindingThisTestObject = c.createObject(root, {'testValue': (function(){return this.width * 3}) })  // use width of Item within 'c'
42     }
43 }