54 lines
1.1 KiB
QML
54 lines
1.1 KiB
QML
|
|
import QtQuick
|
||
|
|
import QtQuick.Controls
|
||
|
|
import QtQuick.Layouts
|
||
|
|
|
||
|
|
Item {
|
||
|
|
width: parent.width/parent.childcount
|
||
|
|
property var editMode: false
|
||
|
|
property var text: ""
|
||
|
|
property var value: ""
|
||
|
|
property var color: "#8C8C8C"
|
||
|
|
height: 40
|
||
|
|
clip: true
|
||
|
|
|
||
|
|
Label {
|
||
|
|
text: parent.text
|
||
|
|
anchors.centerIn: parent
|
||
|
|
font.family: customFontLoader.name
|
||
|
|
font.pixelSize: 15
|
||
|
|
color: parent.color
|
||
|
|
anchors.verticalCenter: parent.verticalCenter
|
||
|
|
verticalAlignment: Text.AlignHCenter
|
||
|
|
}
|
||
|
|
TextField
|
||
|
|
{
|
||
|
|
id: tf
|
||
|
|
visible: false
|
||
|
|
width: parent.width
|
||
|
|
height: parent.height
|
||
|
|
font.pixelSize: 15
|
||
|
|
onTextChanged: {
|
||
|
|
parent.value = text;
|
||
|
|
}
|
||
|
|
onEditingFinished: {
|
||
|
|
parent.value = text;
|
||
|
|
visible = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
MouseArea{
|
||
|
|
anchors.fill: parent;
|
||
|
|
visible: !tf.visible;
|
||
|
|
onDoubleClicked: {
|
||
|
|
|
||
|
|
if (parent.editMode == true)
|
||
|
|
{
|
||
|
|
tf.visible = true;
|
||
|
|
tf.text = parent.text;
|
||
|
|
tf.forceActiveFocus();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|