63 lines
1.7 KiB
QML
63 lines
1.7 KiB
QML
import QtQuick
|
|
import QtQuick.Window
|
|
import Qt.labs.qmlmodels
|
|
|
|
Window {
|
|
width: 400
|
|
height: 400
|
|
visible: true
|
|
|
|
TableView {
|
|
anchors.fill: parent
|
|
columnSpacing: 1
|
|
rowSpacing: 1
|
|
boundsBehavior: Flickable.StopAtBounds
|
|
|
|
model: TableModel {
|
|
TableModelColumn { display: "checked" }
|
|
TableModelColumn { display: "amount" }
|
|
TableModelColumn { display: "fruitType" }
|
|
TableModelColumn { display: "fruitName" }
|
|
TableModelColumn { display: "fruitPrice" }
|
|
|
|
// Each row is one type of fruit that can be ordered
|
|
rows: [
|
|
{
|
|
// Each property is one cell/column.
|
|
checked: false,
|
|
amount: 1,
|
|
fruitType: "Apple",
|
|
fruitName: "Granny Smith",
|
|
fruitPrice: 1.50
|
|
},
|
|
{
|
|
checked: true,
|
|
amount: 4,
|
|
fruitType: "Orange",
|
|
fruitName: "Navel",
|
|
fruitPrice: 2.50
|
|
},
|
|
{
|
|
checked: false,
|
|
amount: 1,
|
|
fruitType: "Banana",
|
|
fruitName: "Cavendish",
|
|
fruitPrice: 3.50
|
|
}
|
|
]
|
|
}
|
|
delegate: TextInput {
|
|
text: model.display
|
|
padding: 12
|
|
selectByMouse: true
|
|
|
|
onAccepted: model.display = text
|
|
|
|
Rectangle {
|
|
anchors.fill: parent
|
|
color: "#efefef"
|
|
z: -1
|
|
}
|
|
}
|
|
}
|
|
}
|