How to change Qt 5.7 virtual keyboard layout/locale

那年仲夏 提交于 2019-12-14 03:45:37

问题


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.

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:


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



来源:https://stackoverflow.com/questions/40507390/how-to-change-qt-5-7-virtual-keyboard-layout-locale

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!