-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.qml
195 lines (168 loc) · 5.14 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import QmlProperties 1.0
ApplicationWindow {
visible: true
width: 640
height: 480
property int margin: 11
// title: qsTr("Tabs")
title: qmlProperty.name
property int someNumber: 100
function myQmlFunction(msg) {
console.log("Got message:", msg)
return "some return value"
}
property color mainTextCOlor: "green"
QmlProperty {
id: qmlProperty
text: "QML signal and Property"
}
SwipeView {
id: swipeView
anchors.fill: parent
currentIndex: tabBar.currentIndex
Page1Form {
ColumnLayout {
id: page1Column
width: parent.width
spacing: 2
Test {
y:50
}
Text {
id:page1Text
// x: 30
// anchors.left: parent
anchors.topMargin: 10
// text: "Signal handler"
text: qmlProperty.name
Component.onCompleted: {
page1Text.color = "red"
}
}
Text {
id:item
x: 150
// text: "QML signal"
text: qmlProperty.text
objectName: "page1Item"
signal qmlSignal(string msg)
MouseArea {
anchors.fill: parent
onClicked: item.qmlSignal("Hello from QML")
}
}
}
ColumnLayout {
width: parent.width
anchors.top: page1Column.bottom
spacing: 15
Text {
text: "offlineStoragePath: " + offlineStoragePath
// anchors.top: page1Column.bottom
color: mainTextColor
}
Text {
text: "QStandardPaths: " + appDataLocation
}
Button {
height: 10
focus: true
text: activeFocus ? "I have active focus!" : "I do not have active focus"
Keys.onPressed: {
if (event.key === Qt.Key_A) {
console.log('Key A was pressed');
event.accepted = true;
}
}
background: Rectangle {
implicitWidth: 100
implicitHeight: 40
color: button.down ? "#d6d6d6" : "#f6f6f6"
border.color: "#26282a"
border.width: 1
radius: 4
}
}
}
Button {
y: 100
objectName: "page1Button1"
text: "Button"
onClicked: qmlProperty.changeText("Text Changed")
}
Button {
y: 150
text: "Http Button"
objectName: "httpButton"
onClicked: qmlProperty.getRequest("https://jsonplaceholder.typicode.com/posts/2")
}
Button {
y: 200
text: "add Setting"
onClicked: qmlProperty.newSetting("setting1", 10)
}
Button {
y: 240
text: "get Setting"
onClicked: qmlProperty.getSetting("setting1")
}
}
Page2Form {
RowLayout {
width: parent.width
spacing: 6
Rectangle {
color: 'teal'
Layout.fillWidth: true
Layout.minimumWidth: 50
Layout.preferredWidth: 100
Layout.maximumWidth: 300
Layout.minimumHeight: 150
Text {
anchors.centerIn: parent
text: parent.width + 'x' + parent.height
}
}
Rectangle {
color: 'plum'
Layout.fillWidth: true
Layout.minimumWidth: 100
Layout.preferredWidth: 200
Layout.preferredHeight: 100
Text {
anchors.centerIn: parent
text: parent.width + 'x' + parent.height
}
}
}
}
Page3Form {
}
Page4Form {
}
Page5Form {
}
}
footer: TabBar {
id: tabBar
currentIndex: swipeView.currentIndex
TabButton {
text: qsTr("Page 1")
}
TabButton {
text: qsTr("Page 2")
}
TabButton {
text: qsTr("Page 3")
}
TabButton {
text: qsTr("Page 4")
}
TabButton {
text: qsTr("Page 5")
}
}
}