Gui*_*pas 5 keyboard textfield qml ios
我正在尝试使用TextField
仅接收中的数字的QML
。我正在使用该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
}
Run Code Online (Sandbox Code Playgroud)
我尝试了其他选项来喜欢inputMethodHints: Qt.ImhDigitsOnly | Qt.ImhNoPredictiveText
,inputMethodHints: Qt.ImhNoPredictiveText
但这些选项在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
inputMethodHints: Qt.ImhDigitsOnly
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3100 次 |
最近记录: |