1   Window {
2     width: 640
3     height: 480
4     visible: true
5     color: "blue"
6     title: qsTr("Hello World")
7     Text {
8            id: label
9            x: 24; y: 24
10           // custom counter property for space presses
11           property int spacePresses: 0
12           anchors.centerIn: parent
13           font.family: "Times"
14           font.pixelSize: 40
15           color: "white"
16           text: "Space pressed: " + spacePresses + " times"
17           // need focus to receive key events
18           focus: true
19           //  handler with some JavaScript
20           Keys.onSpacePressed: {
21               increment()
22           }
23           // zero times on escape
24           Keys.onEscapePressed: {
25               spacePresses = 0
26           }
27           // ) a JavaScript function
28           function increment() {
29               spacePresses = spacePresses + 1
30           }
31    }
32    Rectangle {
33           id: rect
34           x: 200; y: 12
35           width: 76; height: 96
36           color: "lightsteelblue"
37    }
38    Rectangle {
39           id: rect2
40           x: 300; y: 12
41           width: 76; height: 96
42           border.color: "lightsteelblue"
43           border.width: 4
44           radius: 8
45    }
46 }
