-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyInputItem.qml
62 lines (55 loc) · 2 KB
/
MyInputItem.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
import QtQuick
import QtQuick.Controls 2.15
import QtQuick 2.15
import QtQuick.Window 2.15
Item {
id: inputItem
width: parent.width
height: textFieldHeight
property color textColor: "black"
property string textCaption: "Chemical formula"
property alias methodHints: input.inputMethodHints
property alias textInput: input.text
property bool visibleState: true
property bool readOnlyState: false
property int leftMarginText: defaultMarginText
property int textHeigth: 20
readonly property int defaultMarginText: 10
readonly property int textWidth: caption.width
property int textFieldWidth: 160
property int textFieldHeight: 35
property int leftMarginInput: inputItem.leftMarginText + caption.width + inputItem.leftMarginText
property RegularExpressionValidator inputValidator: RegularExpressionValidator { regularExpression: /[0-9.,]+/ }
property string valueBuffer1: ""
property string valueBuffer2: ""
Text {
id: caption
anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: inputItem.leftMarginText }
color: inputItem.textColor
font.pointSize: inputItem.textHeigth
text: inputItem.textCaption
visible: inputItem.visibleState
}
TextField {
id: input
anchors {
left: parent.left
leftMargin: inputItem.leftMarginInput
verticalCenter: parent.verticalCenter
}
width: inputItem.textFieldWidth
height: inputItem.textFieldHeight
visible: inputItem.visibleState
readOnly: inputItem.readOnlyState
validator: inputItem.inputValidator
background: Rectangle {
border.color: "black"
border.width: 2
radius: 10
}
//TODO
Keys.onReturnPressed: calculate()
Keys.onTabPressed: calculate()
}
// }
}