File: methods.qml

package info (click to toggle)
qt6-declarative 6.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 308,920 kB
  • sloc: cpp: 775,911; javascript: 514,247; xml: 10,855; python: 2,806; ansic: 2,253; java: 810; sh: 262; makefile: 41; php: 27
file content (58 lines) | stat: -rw-r--r-- 1,345 bytes parent folder | download | duplicates (2)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import QtQuick
import TestTypes

BirthdayParty {
    id: party
    host: Person {
        name: "Bob Jones"
        shoeSize: 12
    }
    guests: [
        Person { name: "Leo Hodges" },
        Person { name: "Jack Smith" },
        Person { name: "Anne Brown" }
    ]

    property var dresses: [0, 0, 0, 0]

    property var foo: party
    property var bar: console

    property var numeric
    property var stringly

    Component.onCompleted: {
        invite("William Green")
        foo.invite("The Foo")
        bar.log("The Bar")
        numeric = 1;
        stringly = "name";
    }

    function storeElement() {
        ++host.shoeSize
        party.dresses[2] = [1, 2, 3]
    }

    function stuff(sn) {
        // Warning: to not test for signal handlers like this in actual code.
        // Use the helper methods in QQmlSignalNames instead.
        if (sn.substr(0, 2) === "on" && sn[2] === sn[2].toUpperCase())
            return sn
        return "on" + sn.substr(0, 1).toUpperCase() + sn.substr(1)
    }

    function retrieveVar() {
        return guests[numeric][stringly];
    }

    function retrieveString() : string {
        return guests[numeric][stringly];
    }

    property var n1: stuff("onGurk")
    property var n2: stuff("semmeln")
    property var n3: stuff(12)

    property int enumValue: Item.TopRight
}