6
votes

I'm writing a small windows application with Qt 5.7 using qml. For my project I would need to be able to change the virtual keyboard layout. But After hours of reading the docs and trying various things I'm still unable to achieve it.

My Qt installation is default windows installation and it is up to date (just checked if there would be updates).

As you can see here, the keyboard uses en_EN locale despite that my OS locale is fi_FI. And also notice that Language Change button is in disabled state.

enter image description here

I also tried to list available locales from keyboard settings, and I tried to set locale manually via keyboard settings, but layout won't change. Heres my code for those things:

InputPanel {
    id: keyboardPanel
    y: Qt.inputMethod.visible ? parent.height - keyboardPanel.height : parent.height
    anchors.left: parent.left
    anchors.right: parent.right
    Component.onCompleted: {
        console.log("locales available: " + VirtualKeyboardSettings.availableLocales)
        console.log("Locale before changing it: " + VirtualKeyboardSettings.locale)
        VirtualKeyboardSettings.locale = "fi_FI";
        console.log("Locale after changing it: " + VirtualKeyboardSettings.locale)
    }
}

And the result for running that code was (keyboard layout did not change):

qml: locales available: 
qml: Locale before changing it: 
qml: Locale after changing it: fi_FI

I could use custom layout, but I did not understand how you can change to custom layout....

Any help would be greatly appreciated.

1
Did you build the keyboard yourself?Mitch
No.. it is bundled with Qt 5.7 doc.qt.io/qt-5/qtvirtualkeyboard-index.html And I did not build it from sources my self. I understood that it should have multiple locales and layouts in that prebuild version.StefanR
Default locale is not en_EN (there is no such a locale). en_GB is default. In Component.onCompleted: VirtualKeyboardSettings.locale = locale.name you can change locale to ApplicationWindow's one or any other you want.Tomilov Anatoliy
Since the keyboard is compiled by default with only en_GB, you cannot change the locale like that @Orient . And yes, there is no such locale as en_EN, my mistake.StefanR

1 Answers

4
votes

Currently the virtual keyboard only uses English as the default language if no languages are specified when building. This will change soon - likely in Qt 5.8. Until then, you can use the lang-all configuration option when building the module. Alternatively, you can enable individual languages using the lang-<code> option; there's an example on that page that mentions that you'd use CONFIG+=lang-fi for the Finnish language (the author of the keyboard is Finnish :)).