-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.qml
92 lines (83 loc) · 1.87 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
import QtQuick 2.0
import org.qtproject.models 1.0
Rectangle {
width: 800
height: 600
color : "red"
Car
{
id : car_1
carName : "H1"
carBrand : "Hummer"
carPrice : 125000
}
ListView
{
anchors
{
left : parent.left
right : parent.right
top : parent.top
bottom : parent.verticalCenter
}
model : myCarModel
delegate: car_delegate
}
Rectangle
{
width : 200
height : 50
color : "orange"
radius : 15
anchors
{
horizontalCenter : parent.horizontalCenter
bottom : parent.bottom
}
Text
{
anchors.centerIn: parent
text : "Add car_1 to model";
}
MouseArea
{
anchors.fill: parent
onClicked: myCarModel.appendRowFromQml(car_1);
}
}
Component {
id : car_delegate
Rectangle
{
width : 800
height : 50
color : "blue"
Text
{
anchors.left: parent.left
anchors.verticalCenter : parent.verticalCenter
text : model.car_name
}
Text
{
anchors.right: parent.right
anchors.verticalCenter : parent.verticalCenter
text : model.car_price
}
Text
{
anchors.horizontalCenter : parent.horizontalCenter
anchors.verticalCenter : parent.verticalCenter
text : model.car_brand
}
MouseArea
{
anchors.fill: parent
onClicked:
{
model.car_price += 1
}
}
}
}
}