QML 虚拟键盘添加新布局 [英] QML Virtual Keyboard Add New Layout

查看:65
本文介绍了QML 虚拟键盘添加新布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在树莓派的 Yocto 项目上使用 qt qml 5.7.我的项目需要土耳其语的虚拟键盘.QT 虚拟键盘 不支持土耳其语 所以我想创建我的自定义布局.我从 here 作为名称myCustomLayout.qml".

I use qt qml 5.7 on Yocto project for raspberry pi. My project need virtual keyboard for Turkish language. QT Virtual Keyboard has no support Turkish language so i want to create my custom layout. I add my project example layout codes from here as name "myCustomLayout.qml".

我通过以下代码运行我的虚拟键盘显示功能.

And I run my virtual keyboard display function by following codes.

import QtQuick 2.5
import QtQuick.VirtualKeyboard 2.1
import QtQuick.Controls 2.0

InputPanel {
    id: inputPanel
    visible:  Qt.inputMethod.visible
    height:main.height/4
    y:main.height - height
    x:main.width/8
    width: main.width*6/8
    focus: true
}

当我运行虚拟键盘显示功能时,出现的键盘不是我的自定义布局,它仍然是常规的英文键盘布局.如何在我的应用中添加自定义键盘布局?

When I run the virtual keyboard display function, the appearing keyboard was not my custom layout, it still regular English keyboard layout. How can add my custom keyboard layout in my app?

推荐答案

在我的电脑(不是pi)的yocto build path中找到qtvirtualkeyboard文件.

I found qtvirtualkeyboard files in yocto build path in my computer (not pi).

/build/tmp/work/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/qtvirtualkeyboard/5.7.0+gitAUTOINC+626e78c966-r0/git/

/build/tmp/work/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/qtvirtualkeyboard/5.7.0+gitAUTOINC+626e78c966-r0/git/

我通过在 content/layouts 路径中复制 en_GB 文件创建了一个新的 tr_TR 布局文件.我更改了我的 tr_TR main.qml 文件.我通过添加以下几行修改了 virtualkeyboard.pro 文件,如 Mitch 的回答.

I have created a new tr_TR layout files by copying en_GB file in content/layouts path. I changed my tr_TR main.qml file. I have modified virtualkeyboard.pro file like Mitch's answer by add following lines.

contains(CONFIG, lang-tr.*) {
    LAYOUT_FILES += 
        content/layouts/tr_TR/main.qml
}

我还修改了 config.pri 文件.我更改了以下几行:

Also I modified config.pri file. I changed following lines:

# Default language
!contains(CONFIG, lang-.*) {
    contains(QT_CONFIG, private_tests) { # CI or developer build, use all languages
        CONFIG += lang-all
    } else {
        CONFIG += lang-tr_TR
    }
}

# Flag for activating all languages
lang-all: CONFIG += 
#    lang-ar_AR 
#    lang-da_DK 
#    lang-de_DE 
    lang-en_GB 
#    lang-es_ES 
#    lang-fa_FA 
#    lang-fi_FI 
#    lang-fr_FR 
#    lang-hi_IN 
#    lang-it_IT 
#    lang-ja_JP 
#    lang-ko_KR 
#    lang-nb_NO 
#    lang-pl_PL 
#    lang-pt_PT 
#    lang-ru_RU 
#    lang-sv_SE 
    lang-tr_TR 
#    lang-zh_CN 
#    lang-zh_TW

我将更改后的 git 文件复制到 U 盘并在 pi 上打开了我的文件.我重建了 qtvirtualkeyboard:

I copied my changed git file to USB stick and opened my files on pi. I rebuilt qtvirtualkeyboard with:

qmake "CONFIG+=lang-all" qtvirtualkeyboard.pro
make
make install

我终于可以使用我的自定义布局了.

Finally I can use my custom layout.

这篇关于QML 虚拟键盘添加新布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆