Building Qt Virtual Keyboard


This document describes how to build the Qt Virtual Keyboard plugin.

The project is split into the following subprojects:

examples/virtualkeyboard/basic/basic.proQt Virtual Keyboard Demo application
src/virtualkeyboard/import/Qt Virtual Keyboard QML plugin (QtQuick.VirtualKeyboard)
src/virtualkeyboard/plugin/Qt Virtual Keyboard platform input context plugin. This plugin provides the QPlatformInputContext interface for the Qt and is also responsible for loading the Virtual Keyboard Plugins (QtQuick.VirtualKeyboard.Plugins).
src/virtualkeyboard/plugins/A directory containing Qt Virtual Keyboard plugins, such as the Hunspell plugin
src/virtualkeyboard/settings/Qt Virtual Keyboard Settings QML plugin (QtQuick.VirtualKeyboard.Settings)
src/virtualkeyboard/styles/styles.proQt Virtual Keyboard Styles QML plugin (QtQuick.VirtualKeyboard.Styles)
src/virtualkeyboard/virtualkeyboard.proQt Virtual Keyboard module, QML components and layouts

The input methods are implemented either in C++ or QML. Qt Virtual Keyboard provides implementations of PlainInputMethod, MultitapInputMethod and HunspellInputMethod. The MultitapInputMethod is implemented in QML while the others are implemented in C++.

Build Instructions

The Qt Virtual Keyboard can be built for Linux Desktop/X11, Windows Desktop or Boot2Qt targets. The target is automatically detected by QMAKE and requires no special configuration parameters.

Qt Creator is the preferred build environment for Qt Virtual Keyboard as you can then leverage the shadow build functionality and rapidly switch between build targets.

Configuration Options

The table below contains the top-level options for configuring the virtual keyboard features.

-vkb-enable <code>[,<code>]*"Supported language codes or 'all'Enables the specified languageThe specified languages can be explicitly enabled using this option. Each language code has the format language[_country], where:
  • language is a lowercase, two-letter, ISO 639 language code
  • country is an uppercase, two-letter, ISO 3166 country code

This option can be used to define the language support as required. The virtual keyboard can support one or more languages at a time.

For example, -vkb-enable de_DE,fi_FI enables support for the German and Finnish languages.

The virtual keyboard automatically includes all supported languages if no other languages are specified.

-vkb-handwriting[yes|no|t9write]Enables or disabled handwriting inputThis flag enables handwriting input. By default, the first engine available at build time is used. The engines are chosen in the following order: t9write. To force handwriting input using to use a specific engine, specify the engine to be used; for example, -vkb-handwriting t9write.
[-no]-vkb-arrow-keynavigationEnables or disables arrow key navigation for the keyboardAllows controlling the keyboard using the arrow and return keys. This feature is off by default.
-vkb-style[standard|retro]Choose the style of the virtual keyboardThe Qt Virtual Keyboard supports two styles, standard and retro. Both styles will be included in the package, but this option allows you to change the built-in default style.
[-no]-vkb-cangjieEnables or disables the Cangjie input method for Traditional Chinese.This option enables or disables the Cangjie input method for the Traditional Chinese language. The input method is enabled by default if support for Traditional Chinese is enabled.
[-no]-vkb-zhuyinEnables or disables the Zhuyin input method for Traditional Chinese.This option enables or disables the Zhuyin input method for the Traditional Chinese language. The input method is enabled by default if support for Traditional Chinese is enabled.
[-no]-vkb-desktopEnables or disables Desktop integrationBy default, the desktop integration is enabled when the target environment is X11 or Windows desktop. With this option, the desktop integration can be disabled.

Note: For embedded integration, where the InputPanel is instantitated by the application, there is no need to use this option explicitly. The virtual keyboard will not create the desktop input panel if the application creates InputPanel before the focus is set to an input field.

[-no]-vkb-layoutsEnables or disables built-in layoutsBy default, the virtual keyboard plugin contains the English keyboard layout. By specifiying -no-vkb-layouts, the built-in layout(s) are excluded from the virtual keyboard plugin.

Note: In this scenario, the QT_VIRTUALKEYBOARD_LAYOUT_PATH environment variable should be set to the file system directory containing the custom keyboard layouts before running the application.

These options can be passed to configure when doing a full build of Qt. Alternatively, when building only the Qt Virtual Keyboard, you can configure the keyboard using the following command (where SRCDIR points to the source directory of QtVirtualKeyboard):

qmake $SRCDIR -- [options]
disable-hunspelln/aDisables Hunspell integrationHunspell integration is enabled if the Hunspell library is available on the system, or if it is built using the local project file. Integration can be disabled using this option.
vkb-no-bundle-pinyinn/aDisables bundling of pinyin resourcesThis option excludes pinyin resources from the plugin binary. This option may be used to reduce the plugin binary size.
vkb-no-bundle-tcimen/aDisables bundling of tcime resourcesThis option excludes tcime resources from the plugin binary. This option may be used to reduce the plugin binary size.
pinyinlang-zh_CNEnables the Pinyin input method for Simplified Chinese.This option activates the Pinyin input method for the Simplified Chinese language.

As this option activates a particular language, the lang-all option will not be enabled if this option is specified. To build all languages, use CONFIG+=lang-all.

tcimelang-zh_TWEnables the both Cangjie and Zhuyin input methods for Traditional Chinese.This option activates the both Cangjie and Zhuyin input methods for the Traditional Chinese language.

As this option activates a particular language, the lang-all option will not be enabled if this option is specified. To build all languages, use CONFIG+=lang-all.

openwnnlang-ja_JPEnables the OpenWnn input method for Japanese.This option activates the OpenWnn input method for the Japanese language.

As this option activates a particular language, the lang-all option will not be enabled if this option is specified. To build all languages, use CONFIG+=lang-all.

Building Documentation

make docsGenerates documentation

Hunspell Integration

By default, HunspellInputMethod will not be available unless the Hunspell library and development headers are found. For Linux/X11 targets, the Hunspell library can be provided by installing the libhunspell-dev package. Alternatively, the Hunspell sources can be extracted into the src/plugins/hunspell/3rdparty/hunspell directory. The sources are automatically detected by the qmake and the project will be configured to use the local Hunspell. If Hunspell sources are used, then the dictionary files must also be copied into the src/plugins/hunspell/3rdparty/hunspell/data directory.

An example of how the directory structure should look after copying in the Hunspell sources and dictionary files is listed below:

└── hunspell
    ├── data
    │   ├── en_GB.aff
    │   └── en_GB.dic
    └── src
        └── hunspell
            ├── affentry.cxx
            ├── affentry.hxx

T9 Write Integration

T9 Write integration supports the T9 Write Alphabetic and T9 Write CJK engines. Both engines are integrated via T9WriteInputMethod. The input method can be initialized with either of the engines at runtime. The engine selection happens automatically based on input locale and input mode from the keyboard.

T9 Write Compatibility

Qt Virtual Keyboard is compatible with T9 Write v7.5.0 onward.

The latest tested version is v7.8.1.

T9 Write Build Preparations

The contents of the SDK must be either manually copied to the directory structure described below, or by using the script found in the t9write directory.

To unpack the SDK using the script:

$ cd src/plugins/t9write/3rdparty/t9write/
$ python .
└── t9write
    ├─── api
    │   ├─── decuma*.h
    │   ├─── t9write*.h
    │   └─── xxt9w*.h
    ├─── data
    │   ├─── arabic
    │   │   └─── *.bin [T9 Write Arabic]
    │   ├─── hebrew
    │   │   └─── *.bin [T9 Write Hebrew]
    │   ├─── *.bin [T9 Write Alphabetic]
    │   ├─── *.hdb
    │   ├─── *.phd
    │   └─── *.ldb [T9 Write v7.5]
    └─── lib
        ├─── arm
        │   ├─── shared
        │   │   ├─── alphabetic
        │   │   │   └─── *.so
        │   │   └─── cjk
        │   │       └─── *.so
        │   └─── static
        │       ├─── alphabetic
        │       │   └─── *.a / *.o
        │       └─── cjk
        │           └─── *.a / *.o
        ├─── linux-x86
        │   ├─── shared
        │   │   ├─── alphabetic
        │   │   │   └─── *.so
        │   │   └─── cjk
        │   │       └─── *.so
        │   └─── static
        │       ├─── alphabetic
        │       │   └─── *.a / *.o
        │       └─── cjk
        │           └─── *.a / *.o
        └─── win32
            ├─── shared
            │   ├─── alphabetic
            │   │   ├─── *.dll
            │   │   └─── *.lib
            │   └─── cjk
            │       ├─── *.dll
            │       └─── *.lib
            └─── static
                ├─── alphabetic
                │   └─── *.lib / *.obj
                └─── cjk
                    └─── *.lib / *.obj

Note: The above files are from the T9 Write demo SDK for Windows; the contents may vary for other platforms.

Where the contents of each directory are:

apiThis directory should contain all of the API filesThe API files usually located in the "api" and "public" directories of the SDK, but sometimes in the "demo" directory.

When using both Alphabetic and CJK engines at the same time, any overlapping files can be copied from either SDK.

dataThis directory should contain all HWR databases and optionally XT9 databases.HWR database for the T9 Write Alphabetic:
  • _databas_le.bin

HWR database for the T9 Write CJK:

  • cjk_HK_std_le.hdb HongKong Chinese
  • cjk_J_std_le.hdb Japanese
  • cjk_K_mkt_le.hdb Korean
  • cjk_S_gb18030_le.hdb Simplified Chinese
  • cjk_T_std_le.hdb Traditional Chinese

Language database:

  • File extension is either .ldb or .phd
lib/<target>/<linkage>/<engine-variant>Directory structure holding supported target builds.These directories should hold the desired target libraries. If both shared and static libraries are found, shared libraries are preferred.

For example, to enable a static win32 build, copy t9write_alphabetic_rel.obj to lib/win32/static/alphabetic directory.

Finally, the SDK is included in the build by adding CONFIG+=t9write to the qmake command line.

MyScript Text SDK Integration

MyScript Text is designed for building applications that enable the recognition of handwritten text. MyScript Text supports the recognition of isolated characters, cursive, print and superimposed writing. MyScript superimposed writing is integrated into Qt Virtual Keyboard. It enables the recognition of letters, words or parts of words written one over the other, without any explicit separation between consecutive fragments. It is capable of running on memory and CPU constrained devices.

Input handwriting styles of MyScript Text SDK

The end-user can write one word fragment over the other, or one character over the other, as depicted below. Space between two written words are automatically added, so that there is no need for an explicit gesture.

Writing one character over the other
Writing fragments of word over the others

Language coverage of MyScript Text SDK

MyScript Superimposed supports 70 languages.

MyScript Text SDK Packages Installation

The MyScript delivery team can provide you the packages with various .zip archives. To access all the code, tools, and resources needed for building your own handwriting application, extract all the packages in the same destination folder as src/plugins/myscript/3rdparty/myscript.

The file hierarchy should look like below:

└── myscript
    ├─── conf
    ├─── doc
    ├─── edk
    ├─── engine
    │   └─── bin
    │       ├─── lin-arm64
    │       │   └─── *.so
    │       ├─── lin-armv7
    │       │   └─── *.so
    │       ├─── lin-x64
    │       │   └─── *.so
    │       ├─── lin-x86
    │       │   └─── *.so
    │       ├─── win-x64
    │       │   └─── *.dll
    │       ├─── win-x86
    │       │   └─── *.dll
    │       (etc.)
    ├─── rdk
    ├─── resources
    │   ├─── ar
    │   │   └─── *.res
    │   ├─── en_GB
    │   │   └─── *.res
    │   ├─── ja_JP
    │   │   └─── *.res
    │   ├─── ko_KR
    │   │   └─── *.res
    │   ├─── zh_CN
    │   │   └─── *.res
    │   (etc.)
    ├─── tools
    └─── voim
        ├─── api
        ├─── bin
        │   ├─── lin-arm64
        │   │   └─── *.so
        │   ├─── lin-armv7
        │   │   └─── *.so
        │   ├─── lin-x64
        │   │   └─── *.so
        │   ├─── lin-x86
        │   │   └─── *.so
        │   ├─── win-x64
        │   │   └─── *.dll
        │   ├─── win-x86
        │   │   └─── *.dll
        │   (etc.)
        └─── conf

The description for the contents of each directory are:

confContains the language configuration files that the Engine uses to configure language resources.
docContains the HTML documentation files. The file index.html displays the main page.
edkContains the Engine Development Kit and handwriting programming elements for each supported programming language API, including code samples.
engineContains libraries of each engine object, depending on the target platforms it could be SO, A, or DLL.
rdkContains the Resource Development Kit, i.e. tools and examples for creating custom resources.
resourcesContains resource files with the /c .res extension. They are binary assets used at run time by the different MyScript technologies to achieve the various recognition tasks.
toolsContains useful programmer tools including InkTool for ink testing.
voimContains libraries of MyScript Text Input Method. It is an extension SDK to the MyScript Text recognition system and designed for building input methods using handwriting recognition easily and quickly.

Setting the Certificate of MyScript Text SDK

A valid certificate is mandatory to use the MyScript Text SDK. This is a security measure that uniquely identifies you as a legitimate customer of MyScript technologies. The certificate helps MyScript trace customers' identify and the products that have been purchased.

The certificate is delivered in the /c [your_login] package. When you unzip this package, the certificate is automatically put in the appropriate location. This ensure that the certificate is instantly working within the services and code samples that you have been provided with.

How to build Qt Virtual Keyboard with MyScript Text SDK

The MyScript Text SDK is included in the build of Qt Virtual Keyboard by either adding CONFIG+=handwriting or CONFIG+=myscript to the qmake command line.

Static builds

The virtual keyboard can be built and linked statically against the application. This implies that Qt is also built statically (using the -static option in the configure command line).

Static builds of the virtual keyboard are enabled by adding CONFIG+=static to the qmake command line and then rebuilding.

Some third party modules used by the virtual keyboard are always built as shared libraries (e.g. Hunspell).

Using the static plugin

The following section should be added to the application project file that uses the statically built virtual keyboard.

static {
    QTPLUGIN += qtvirtualkeyboardplugin
    QT += svg

QTPLUGIN causes qmake to pull linker dependencies for the virtual keyboard plugin. The SVG module is required as an extra dependency for Qt, since the SVG format is required by the default styles.

From here on, using a statically built virtual keyboard is no different from the normal case.


Desktop Targets

Add a Deploy Step that executes the make install command, then deploy using the Deploy All command.

Boot2Qt Targets

The installation is done by copying the necessary files to the memory card, or by using the adb push command.

© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.