diff options
Diffstat (limited to 'doc/src/snippets/declarative/codingconventions/javascript.qml')
| -rw-r--r-- | doc/src/snippets/declarative/codingconventions/javascript.qml | 33 | 
1 files changed, 33 insertions, 0 deletions
| diff --git a/doc/src/snippets/declarative/codingconventions/javascript.qml b/doc/src/snippets/declarative/codingconventions/javascript.qml new file mode 100644 index 0000000..64b5a40 --- /dev/null +++ b/doc/src/snippets/declarative/codingconventions/javascript.qml @@ -0,0 +1,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] +} | 
