-
Notifications
You must be signed in to change notification settings - Fork 0
/
12_custom_components.qml
58 lines (45 loc) · 1.2 KB
/
12_custom_components.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
Rectangle {
width: 400; height: 100; color: "lightblue"
LineEdit {
id: lineEdit
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 16
width: 300; height: 50
}
Text {
anchors.top: lineEdit.bottom
anchors.topMargin: 12
anchors.left: parent.left
anchors.leftMargin: 16
text: "<b>Summary:</b> " + lineEdit.text
}
Image {
id: clearButton
source: "../images/clear.svg"
anchors { right: parent.right; rightMargin: 4
verticalCenter: lineEdit.verticalCenter }
opacity: lineEdit.text === "" ? 0.25 : 1.0
MouseArea {
anchors.fill: parent
onClicked: lineEdit.text = "" // binding broken here!
}
}
}
// LineEdit.qml
import QtQuick 2.0
Rectangle {
property string text: textInput.text
border.color: "green"
color: "white"
radius: 4; smooth: true
clip: true
TextInput {
id: textInput
anchors.fill: parent
anchors.margins: 2
text: "Enter text..."
color: focus ? "black" : "gray"
font.pixelSize: parent.height - 4
}
}