MyTextInput.qml
import QtQuick 2.4
Rectangle {
id:singleText
width: input.contentWidth<1 ? 1 : input.contentWidth + 1
height: input.contentHeight + 5
color: "white"
border.color: "lightgrey"
property string inputValue: ""
radius: 4
TextInput {
anchors.fill: parent
anchors.margins: 2
focus: true
text: qsTr(singleText.inputValue)
font.pixelSize: 20
}
}
调用:
MyTextInput {
id: textServer
x: 8
y: 120
width: 173
height: 30
inputValue: "127.0.0.1"
}