aboutsummaryrefslogtreecommitdiffstats
path: root/examples/Tutorial/MainWindow.qml
blob: c8dbfe29ea432f1173f528dc7f1387bc907a63c9 (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
34
35
36
37
/***************************************************************************************************
 Copyright (C) 2025 The Qt Company Ltd.
 SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
***************************************************************************************************/
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

ApplicationWindow {
    id: window; width: 220; height: 240; visible: true; title: "Names"

    NameList { id: names }

    ColumnLayout {
        anchors.fill: parent

        TextField {
            Layout.fillWidth: true; leftPadding: 10; focus: true;
            placeholderText: "Enter a name"
            onAccepted: {
                let name = text.trim();
                if (name)
                    names.add(name);
                clear();
            }
        }

        ListView {
            model: names
            Layout.fillWidth: true; Layout.fillHeight: true; clip: true
            delegate: Text {
                required property string item
                text: item; leftPadding: 10
            }
        }
    }
}