|
| 1 | +import QtQuick |
| 2 | +import QtQuick.Controls 2.15 |
| 3 | +import QtQuick 2.15 |
| 4 | +import QtQuick.Window 2.15 |
| 5 | + |
| 6 | + |
| 7 | +Item { |
| 8 | + id: inputItem |
| 9 | + |
| 10 | + width: parent.width |
| 11 | + height: textFieldHeight |
| 12 | + |
| 13 | + property color textColor: "black" |
| 14 | + property string textCaption: "Chemical formula" |
| 15 | + property alias methodHints: input.inputMethodHints |
| 16 | + property alias textInput: input.text |
| 17 | + property bool visibleState: true |
| 18 | + property bool readOnlyState: false |
| 19 | + property int leftMarginText: defaultMarginText |
| 20 | + property int textHeigth: 20 |
| 21 | + readonly property int defaultMarginText: 10 |
| 22 | + readonly property int textWidth: caption.width |
| 23 | + property int textFieldWidth: 160 |
| 24 | + property int textFieldHeight: 35 |
| 25 | + property int leftMarginInput: inputItem.leftMarginText + caption.width + inputItem.leftMarginText |
| 26 | + property RegularExpressionValidator inputValidator: RegularExpressionValidator { regularExpression: /[0-9.,]+/ } |
| 27 | + |
| 28 | + Text { |
| 29 | + id: caption |
| 30 | + anchors { verticalCenter: parent.verticalCenter; left: parent.left; leftMargin: inputItem.leftMarginText } |
| 31 | + color: inputItem.textColor |
| 32 | + font.pointSize: inputItem.textHeigth |
| 33 | + text: inputItem.textCaption |
| 34 | + visible: inputItem.visibleState |
| 35 | + } |
| 36 | + |
| 37 | + TextField { |
| 38 | + id: input |
| 39 | + anchors { |
| 40 | + left: parent.left |
| 41 | + leftMargin: inputItem.leftMarginInput |
| 42 | + verticalCenter: parent.verticalCenter |
| 43 | + } |
| 44 | + width: inputItem.textFieldWidth |
| 45 | + height: inputItem.textFieldHeight |
| 46 | + visible: inputItem.visibleState |
| 47 | + readOnly: inputItem.readOnlyState |
| 48 | + validator: inputItem.inputValidator |
| 49 | + |
| 50 | + background: Rectangle { |
| 51 | + border.color: "black" |
| 52 | + border.width: 2 |
| 53 | + radius: 10 |
| 54 | + } |
| 55 | + } |
| 56 | + // } |
| 57 | +} |
0 commit comments