【发布时间】:2016-03-24 08:30:20
【问题描述】:
我正在尝试使用仅接收 QML 中的数字的 TextField。我正在使用inputMethodHints 属性使设备键盘只显示数字。它在 Android 中运行良好,但当我在 iOS 中运行它时,它会显示完整的键盘,包括数字、字符和预测词。
代码如下:
TextField {
id: numeroTelefoneTextField
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
width: parent.width * 0.70
height: parent.height * 0.6
placeholderText: qsTr("Seu número")
font.bold: true
validator: RegExpValidator{regExp: /\d+/}
inputMethodHints: Qt.ImhDigitsOnly
}
我尝试了其他选项来喜欢inputMethodHints: Qt.ImhDigitsOnly | Qt.ImhNoPredictiveText 和inputMethodHints: Qt.ImhNoPredictiveText,但这些选项在 iOS 中都不起作用。
【问题讨论】:
-
对于(0-12)之间`验证器:IntValidator {底部:1;顶部:12} 焦点:真`
标签: ios keyboard qml textfield