summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative/codingconventions/javascript.qml
blob: 64b5a4001f04dcc1ebd26925825adec8b82a620a (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
32
33
import Qt 4.7

Rectangle {

//![0]
Rectangle { color: "blue"; width: parent.width / 3 }
//![0]

//![1]
Rectangle {
    color: "blue"
    width: {
        var w = parent.width / 3
        console.debug(w)
        return w
    }
}
//![1]

//![2]
function calculateWidth(object)
{
    var w = object.width / 3
    // ...
    // more javascript code
    // ...
    console.debug(w)
    return w
}

Rectangle { color: "blue"; width: calculateWidth(parent) }
//![2]
}