diff --git a/CMakeLists.txt b/CMakeLists.txt index de27f66..5b71f15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ qt_add_qml_module(${TARGET_APP} QML_FILES Main.qml QML_FILES ListPage.qml + QML_FILES ListItemDelegate.qml ) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. diff --git a/ListItemDelegate.qml b/ListItemDelegate.qml new file mode 100644 index 0000000..eee6822 --- /dev/null +++ b/ListItemDelegate.qml @@ -0,0 +1,19 @@ +import QtQuick + +Item { + id: myItem + required property string name + required property string info + property int fontSize: 16 + + width: parent.width + height: 40 + Column { + Text { + text: 'Name: ' + myItem.name + } + Text { + text: 'Info: ' + myItem.info + } + } +} diff --git a/ListPage.qml b/ListPage.qml index 03ccefa..bcf8847 100644 --- a/ListPage.qml +++ b/ListPage.qml @@ -5,33 +5,15 @@ import QtQuick.Controls.Material Page { id: page - Component { - id: contactDelegate - Item { - id: myItem - required property string name - required property string info - width: parent.width - height: 40 - Column { - Text { - text: 'Name: ' + myItem.name - } - Text { - text: 'Number: ' + myItem.info - } - } - } - } - ListView { anchors.fill: parent model: mainModel - delegate: contactDelegate + delegate: ListItemDelegate {} highlight: Rectangle { color: "lightsteelblue" radius: 5 } focus: true + clip: true } }