File: Page.qml

package info (click to toggle)
qasync 0.28.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 336 kB
  • sloc: python: 1,849; makefile: 10
file content (65 lines) | stat: -rw-r--r-- 1,458 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
59
60
61
62
63
64
65
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.Material 2.15
import QtQuick.Layouts 1.15

Item {
    ExampleService {
        id: service

        // handle value changes inside the service object
        onValueChanged: {
            // use value
        }
    }

    Connections {
        target: service

        // handle value changes with an external Connection
        function onValueChanged(value) {
            // use value
        }
    }

    ColumnLayout {
        anchors {
            fill: parent
            margins: 10
        }

        RowLayout {
            Layout.fillWidth: true

            Button {
                id: button
                Layout.preferredWidth: 100
                enabled: !service.isLoading

                text: {
                    return service.isLoading ? qsTr("Loading...") : qsTr("Fetch")
                }
                onClicked: function() {
                    service.fetch(url.text)
                }
            }

            TextField {
                id: url
                Layout.fillWidth: true
                enabled: !service.isLoading
                text: qsTr("https://jsonplaceholder.typicode.com/todos/1")
            }
        }

        TextEdit {
            id: text
            Layout.fillHeight: true
            Layout.fillWidth: true

            // react to value changes from other widgets
            text: service.value
        }
    }

}