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 Qt.labs.qmlmodels
ListModel {
ListElement {
name: "Bill Smith"
number: "555 3264"
}
ListElement {
name: "John Brown"
number: "555 8426"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
ListElement {
name: "Sam Wise"
number: "555 0473"
}
TableModel {
TableModelColumn { display: "name" }
TableModelColumn { display: "color" }
rows: [
{
"name": "cat",
"color": "black"
},
{
"name": "dog",
"color": "brown"
},
{
"name": "bird",
"color": "white"
}
]
}

View file

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