native: improve table

This commit is contained in:
Johannes Jöns 2024-07-10 12:40:38 +02:00
parent 9fe3977a25
commit 67ce6b4430
2 changed files with 38 additions and 49 deletions

View file

@ -1,32 +1,22 @@
import QtQuick import QtQuick
import Qt.labs.qmlmodels
ListModel { TableModel {
ListElement { TableModelColumn { display: "name" }
name: "Bill Smith" TableModelColumn { display: "color" }
number: "555 3264"
} rows: [
ListElement { {
name: "John Brown" "name": "cat",
number: "555 8426" "color": "black"
} },
ListElement { {
name: "Sam Wise" "name": "dog",
number: "555 0473" "color": "brown"
} },
ListElement { {
name: "Sam Wise" "name": "bird",
number: "555 0473" "color": "white"
} }
ListElement { ]
name: "Sam Wise"
number: "555 0473"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
} }

View file

@ -30,28 +30,27 @@ Window {
border.width: 5 border.width: 5
border.color: getColors().accent border.color: getColors().accent
color: getColors().midlight color: getColors().midlight
}
Component { TableView {
id: contactDelegate anchors.fill: parent
Item {
width: 180; height: 40 columnSpacing: 1
Column { rowSpacing: 1
Text { clip: true
text: '<b>Name:</b> ' + name
color: getColors().text model: Data {}
} delegate: Rectangle {
Text { color: getColors().base
text: '<b>Number:</b> ' + number implicitWidth: 100
color: getColors().text implicitHeight: 50
} border.width: 1
}
Text {
text: display
color: getColors().text
anchors.centerIn: parent
} }
} }
ListView {
anchors.fill: parent
model: Data {}
delegate: contactDelegate
}
} }
} }