Search code examples
qtqmlvirtual-keyboard

How can I show on my keyboard only numbers with qt


I'm using Qt Quick Virtual Keyboard on my project and when I click on an object I want to show the keyboard but just the numbers. How can I do that?

This is what I'm trying to do

just showing the numeric keyboard like this


Solution

  • You can use Qt.ImhFormattedNumbersOnly which allows only number input. This includes also decimal point and minus sign.

    Example usage:

    TextField {
        id: your_id
    
        placeholderText: qsTr("სახელი")
    
        inputMethodHints: Qt.ImhFormattedNumbersOnly
    }