7

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.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
StefanR
  • 676
  • 10
  • 20
  • Did you build the keyboard yourself? – Mitch Nov 09 '16 at 13:01
  • No.. it is bundled with Qt 5.7 http://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 Nov 09 '16 at 13:03
  • 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 Sep 26 '17 at 06:09
  • 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 Sep 26 '17 at 06:36

1 Answers1

5

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 :)).

Mitch
  • 23,716
  • 9
  • 83
  • 122
  • Thanks a lot! I think they should mention this also in the docs... Or maybe I just missed it? – StefanR Nov 09 '16 at 13:39
  • It says it below the Finnish example: `The virtual keyboard automatically includes the English language if no other languages are specified.` It's not a good default behaviour though. :) – Mitch Nov 09 '16 at 13:40
  • Could you clarify, how do I enable the `lang-all` configuration option? – Tor Klingberg Jan 23 '18 at 16:45
  • @TorKlingberg, just as you would for `lang-fi`: `CONFIG+=lang-all`. – Mitch Jan 23 '18 at 18:23
  • No I mean, where do I put that? – Tor Klingberg Jan 23 '18 at 18:24
  • Oh right. You pass it to qmake: `qmake CONFIG+=lang-all qtvirtualkeyboard.pro`. You can also set it in Creator in the additional arguments field: http://doc.qt.io/qtcreator/creator-build-settings.html#qmake-build-steps – Mitch Jan 23 '18 at 18:28