-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.qml
106 lines (99 loc) · 2.64 KB
/
main.qml
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import QtQuick 2.14
import QtQuick.Window 2.12
import QtQuick.Controls 2.1
import Qt.labs.qmlmodels 1.0
ApplicationWindow {
visible: true
width: 640
height: 480
TableView {
anchors.fill: parent
model: TableModel {
// TableModel is designed to work with JavaScript/JSON data, where each row is a simple key-pair object
// without requiring the creation of a custom QAbstractTableModel subclass in C++.
// Each TableModelColumn represents a column in a model and selects property to show
TableModelColumn { display: "checked" }
TableModelColumn { display: "amount" }
TableModelColumn { display: "type" }
TableModelColumn { display: "price" }
// Model data row representing here one type of fruit that can be ordered
rows: [
// Each property is one cell/column.
{
checked: false,
amount: 1,
type: "Apple",
price: 1.50
},
{
checked: true,
amount: 4,
type: "Orange",
price: 2.50
},
{
checked: false,
amount: 1,
type: "Banana",
price: 3.50
},
{
checked: true,
amount: 6,
type: "Cranberry",
price: 5.10
},
{
checked: true,
amount: 8,
type: "Potato",
price: 2.20
}
]
}
delegate: DelegateChooser {
// DelegateChooser allows a view to use different delegates for different types of items in the model.
// Here you can do almost everything to tweak your cells.
DelegateChoice {
column: 0
// For 1st column we use CheckBox component
delegate: CheckBox {
enabled: false
width: 50
checked: model.display
}
}
DelegateChoice {
column: 1
// For 2nd column we use ProgressBar component
delegate: ProgressBar {
enabled: false
width: 100
from: 0.0
to: 10.0
value: model.display
}
}
DelegateChoice {
column: 2
// For 3rd column we use TextField component
delegate: TextField {
implicitWidth: 140
font.capitalization: Font.AllUppercase
text: model.display
readOnly: true
}
}
DelegateChoice {
column: 3
// For 4rd column we use TextField component with text prepared by template
delegate: TextField {
implicitWidth: 80
font.bold: true
text: "$ " + model.display
readOnly: true
}
}
}
}
}