How to enable Virtual Keyboard Languages



  • Hello,

    I'm using c++ and qt quick to develop my app and it runs on raspberry pi. I have a qml file called KeyboardPanel.qml and it has the following:

    import QtQuick 2.7
    import QtQuick.VirtualKeyboard 2.1
    import QtQuick.VirtualKeyboard.Settings 2.0
    
    InputPanel {
    
        id: inputPanel
        Component.onCompleted:{
            VirtualKeyboardSettings.styleName = "retro"
            console.log("locales available: " + VirtualKeyboardSettings.availableLocales)
            console.log("Locale before changing it: " + VirtualKeyboardSettings.locale)
            VirtualKeyboardSettings.locale = "ru_RU";
            console.log("Locale after changing it: " + VirtualKeyboardSettings.locale)
            VirtualKeyboardSettings.customLayoutsOnly = true
        }
    
        y: 5000
        x: 5000
        height: 600
        width: 800
        states: State {
            name: "visible"
            when: inputPanel.active
            PropertyChanges {
                target: inputPanel
                y: 450
                x: 550
            }
        }
        transitions: Transition {
            from: ""
            to: "visible"
            reversible: true
            ParallelAnimation {
                NumberAnimation {
                    properties: "y"
                    duration: 500
                    easing.type: Easing.InOutQuad
                }
            }
        }
    }
    
    

    The keyboard shows up and works fine on text fields, but I cannot add additional languages.

    Thanks in advance!



  • Hi! Did you check that availableLocales : list<string> contains the locales you need?



  • Yes I do check it like

    console.log("locales available: " + VirtualKeyboardSettings.availableLocales)
    

    It is empty.



  • The documentation (http://doc.qt.io/qt-5/qml-qtquick-virtualkeyboard-settings-virtualkeyboardsettings.html#locale-prop) says:

    locale : string
    (...)
    If the locale setting is incorrect, or it is not in the list of supported locales, it is ignored and the default setting is used instead.

    A locale is supported if it is included in the list of availableLocales.

    And in http://doc.qt.io/qt-5/qml-qtquick-virtualkeyboard-settings-virtualkeyboardsettings.html#availableLocales-prop it says:

    availableLocales : list<string>
    (...)
    This list is read-only and depends on the build-time configuration of the virtual keyboard.

    So I'd conclude that you have to rebuild VirtualKeyboard with different configuration.



  • I build qt 5.8 on raspberry like:

    ./configure -v -opengl es2 -qt-freetype -device linux-rasp-pi-g''+ -device-option CROSS_COMPILE=/usr/bin/ -optimized-qmake -reduce-exports -release -qt-pcre -qt-libpng -make libs -prefix /usr/local/qt5

    How can I rebuild only virtualkeyboard module?
    Can I do the same on windows?

    Thanks


  • Lifetime Qt Champion

    Hi,

    You don't need to rebuild the whole Qt.
    Get the module sources and then use the classic qmake/make/make install.

    Take the time to checkout if there's any option you can passe to get more locale supported.



  • I have tried to compile the module. Then I compiled the whole Qt and still cannot get it working


  • Lifetime Qt Champion

    What configuration did you give when compiling the module ?



  • @SGaist

    I just copy the source from git repository.

    1. qmake qtvirtualkeyboard.pro
    2. make
    3. make install

  • Lifetime Qt Champion

    Try with qmake "CONFIG+=lang-all".



  • @SGaist

    Thank you! It works!



  • Hi when i do make i get this errors:

    cd virtualkeyboard/ && ( test -e Makefile || /usr/lib/x86_64-linux-gnu/qt5/bin/qmake /home/devel/Qt5.7.1/5.7/Src/qtvirtualkeyboard/src/virtualkeyboard/virtualkeyboard.pro -o Makefile ) && make -f Makefile
    make[2]: Entering directory '/home/devel/Qt5.7.1/5.7/Src/qtvirtualkeyboard/src/virtualkeyboard'
    g++ -c -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -O2 -fvisibility=hidden -fvisibility-inlines-hidden -std=c++0x -fno-exceptions -Wall -W -D_REENTRANT -fPIC -DQT_VIRTUALKEYBOARD_DEFAULT_STYLE="default" -DQT_VIRTUALKEYBOARD_DESKTOP -DQT_VIRTUALKEYBOARD_HAVE_XCB -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_PLUGIN -DQT_QUICK_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtQuick -isystem /usr/include/x86_64-linux-gnu/qt5/QtQml -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui/5.3.2 -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui/5.3.2/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.3.2 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore/5.3.2/QtCore -isystem /usr/include/x86_64-linux-gnu/qt5/QtNetwork -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I.moc -o .obj/inputcontext.o inputcontext.cpp
    inputcontext.cpp: In member function ‘void QtVirtualKeyboard::InputContext::setSelectionOnFocusObject(const QPointF&, const QPointF&)’:
    inputcontext.cpp:566:5: error: ‘setSelectionOnFocusObject’ is not a member of ‘QPlatformInputContext’
    QPlatformInputContext::setSelectionOnFocusObject(anchorPos, cursorPos);
    ^
    inputcontext.cpp: In member function ‘void QtVirtualKeyboard::InputContext::update(Qt::InputMethodQueries)’:
    inputcontext.cpp:669:66: error: ‘ImInputItemClipRectangle’ is not a member of ‘Qt’
    QRectF inputItemClipRect = d->inputContext->inputMethodQuery(Qt::ImInputItemClipRectangle).toRectF();
    ^
    inputcontext.cpp:670:59: error: ‘ImAnchorRectangle’ is not a member of ‘Qt’
    QRectF anchorRect = d->inputContext->inputMethodQuery(Qt::ImAnchorRectangle).toRectF();
    ^
    inputcontext.cpp:671:59: error: ‘ImAnchorRectangle’ is not a member of ‘Qt’
    QRectF cursorRect = d->inputContext->inputMethodQuery(Qt::ImAnchorRectangle).toRectF();
    ^
    Makefile:641: recipe for target '.obj/inputcontext.o' failed
    make[2]: *** [.obj/inputcontext.o] Error 1
    make[2]: Leaving directory '/home/devel/Qt5.7.1/5.7/Src/qtvirtualkeyboard/src/virtualkeyboard'
    Makefile:40: recipe for target 'sub-virtualkeyboard-make_first' failed
    make[1]: *** [sub-virtualkeyboard-make_first] Error 2
    make[1]: Leaving directory '/home/devel/Qt5.7.1/5.7/Src/qtvirtualkeyboard/src'
    Makefile:40: recipe for target 'sub-src-make_first' failed
    make: *** [sub-src-make_first] Error 2

    Any idea?


  • Lifetime Qt Champion

    Hi,

    You are trying to build the module that is provided with Qt 5.7.1 with the Qt version installed by your distribution which is 5.3.2. Use the full path to your 5.7.1 qmake when building the module.



  • I worked for me now too.
    I did it in Qt Creator. Open the project and:
    -In "Build Step" qmake, add in additional arguments: CONFIG+=lang-all
    -Add Build Step "make" with argumant "install"


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.