QML TextInput:仅用于筛选浮点值的inputMask
我使用的是QtQuick 1.0,我希望使用TextInput元素和input只获取数字和。。要仅获取数字,我使用以下代码:QML TextInput:仅用于筛选浮点值的inputMask,qml,Qml,我使用的是QtQuick 1.0,我希望使用TextInput元素和input只获取数字和。。要仅获取数字,我使用以下代码: TextInput { id: textInput anchors.centerIn : inputArea font.family : "Helvetica" font.pixelSize: textSize color: "black" maximumLength: 5 smooth: true inp
TextInput {
id: textInput
anchors.centerIn : inputArea
font.family : "Helvetica"
font.pixelSize: textSize
color: "black"
maximumLength: 5
smooth: true
inputMask: "99999"
readOnly: isReadOnly
}
我只能输入数字。我应该如何扩展它以获得。另外?在几次运行之后,我得出了以下解决方案:
TextInput {
id: textInput
anchors.centerIn : inputArea
font.family : "Helvetica"
font.pixelSize: textSize
color: "black"
maximumLength: 5
smooth: true
validator : RegExpValidator { regExp : /[0-9]+\.[0-9]+/ }
readOnly: isReadOnly
}
经过几次运行,我得出了以下解决方案:
TextInput {
id: textInput
anchors.centerIn : inputArea
font.family : "Helvetica"
font.pixelSize: textSize
color: "black"
maximumLength: 5
smooth: true
validator : RegExpValidator { regExp : /[0-9]+\.[0-9]+/ }
readOnly: isReadOnly
}
您还可以使用:
您还可以使用: