qtqmlqtvirtualkeyboard

QtVirtualKeyboard how to set default input method?


When the keyboard opens, the default layer is shown with letters

enter image description here

How to do that by default shown a layer with numbers?

enter image description here


Solution

  • Qt virtual keyboard follows inputMethodHints. So, you can e.g. create a form with TextField QML types and set different inputMethodHints for different fields like name, phone number, pin code etc. When you change the field keyboard changes its mode. You can set Qt.ImhDigitsOnly restrictive mode for pin code field to only accept numbers turning keyboard to a keypad.

    If your keyboard opens with a number layout in a specific text input field it sounds like Qt.ImhPreferNumbers or something like that is set to inputMethodHints. You could try to figure out who sets the value and test to reset by setting it explicitly to Qt.ImhNone.