Qml TextField - numeric keypad

1

I'm trying to use a TextField that only receives QML numbers. It is using the inputMethodHints property to make the device show only the numeric keypad. It works fine on Android but when I run on iOS it shows the full keyboard with digits, characters and suggested words.

Code below:

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
}

I've tried other options like inputMethodHints: Qt.ImhDigitsOnly | Qt.ImhNoPredictiveText and only inputMethodHints: Qt.ImhNoPredictiveText but none of these options works on iOS.

    
asked by anonymous 17.12.2015 / 19:46

1 answer

0

I solved the problem by removing validators , but I do not know why it only worked without the validators.

Code below:

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
}
    
18.12.2015 / 13:17