Qt5 Input Method Is Not Set

Hi there!

We are developing a touch-based Qt 5.7 Application on the Apalis imx6 board. For our Image we used angstrom-qt5-x11-image (V2.7) as a base and modified it by adding some recipes on our own.

For the most part, everything works fine. But when we use the QVirtualKeyboard, for example when we want to put text into a TextBox, I can touch the keys but no text gets added. Instead I get the console output:
“input method is not set”

When I attach a USB-Mouse and click into the TextBox entering Text with the QVirtualKeyboard works and the console output is gone.

I already contacted the Qt Support for this, but as we are not using the Qt Device Creation Image they are not really able to help - but they think it has something to do with the BSP.

So, maybe someone has encountered something similar and can help me or point me in the right direction?

Thanks in advance!

I’m not quite following your description but could it be that you are just missing fonts?

No, because when I click in the field with an attached usb-mouse I can use the virtual keyboard as it is intended. And the console output is also gone.

I am currently building the standard bsp (angstrom-qt5-x11-image) to see if I get the same behaviour there. If it works I will reapply all our changes step by step until I get the error.

1) In your main.cpp you included the definition below:

qputenv ("QT_IM_MODULE", QByteArray ("qtvirtualkeyboard"));

Before QGuiApplication.

2) Added import QtQuick.VirtualKeyboard 2.1 into your QML?

3) Always set inputMethodHints.

4) In your text entry, change Text to TextField and use the following:

TextField {
Id: idXYZ
InputMethodHints: Qt.ImhUppercaseOnly | Qt.ImhDigitsOnly
     }

Cleiton Bueno

Blog | Linkedin | B2Open

Thank you for your help, but I still get the same error.

So I tried it with the “standard” image, only applied the patches to get our touch screen working and install the qtvirtualkeyboard package and still getting the same “input method is not set” error.

It is really strange as we had this already working with an older BSP and Qt5.5

Not sure how that can be BSP related, since as far as I understand the touch screen works otherwise… But there is of course integration issues on all layers which can influence behavior of an application.

A quick grep in the virtual keyboard source code shows

bool virtualKeyClick(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers, bool isAutoRepeat)
{
    Q_Q(InputEngine);
    bool accept = false;
    if (inputMethod) {
        accept = inputMethod->keyEvent(key, text, modifiers);
        if (!accept) {
            accept = defaultInputMethod->keyEvent(key, text, modifiers);
        }
        emit q->virtualKeyClicked(key, text, modifiers, isAutoRepeat);
    } else {
        qWarning() << "input method is not set";
    }
    return accept;
}

So “inputMethod” is not set… Not sure how or who is supposed to set that… Maybe enable logging helps a bit (I think setting the environment variable QT_LOGGING_RULES="qt.virtualkeyboard=true" should show more).

Input methods is about internatinonalitzation. Maybe there are some prerequists missing in our BSP… It seems that there is a way to disable input method using QT_IM_MODULE=simple (see I18N/InputMethods - Fedora Project Wiki)

Thanks for the answer!

I did some debugging in the sources of virtualkeyboard and it seems that when the virtualkeyboard is opened, the Textfield loses its focus and so this “inputMethod” is not set.
As it also happens with the basic Virtualkeyboard example I reopened the issue with QtSupport and maybe they will find a solution for this problem.

As a small update from our side:
I created a completely new image recipe, based on core-image-weston and no longer on the angstrom-qt5-x11-image - and now the problem is gone.
(We are not using weston, but the eglfs platform plugin from qt)

And as this solves also some problems we had with X11 (i.e. missing vsync), we will use this approach for now.

Thanks for sharing!

We had exactly the same problem with Qt 5.7 and Qt 5.8 on different board (even not a Toradex one).

We found out that USB keyboard must be connected to our device, otherwise no input method is registered. With USB keyboard the PlainInputMethod (class in Qt) is registered. The strangest issue for us was that we had a tablet with very similar BSP, but the virtual keyboard worked w/o any issue. We realized that there were simple “keyboards” (i.e. volume buttons and power key) on tablet. That was enough.

So the solution for us was to create simple a simple virtual gpio-keys keyboard with one button (KEY_ISO for us, but it doesn’t matter) in Linux.

Ok, thanks. But all our board have at least a wake-up key defined.

I’m a newbie here so sorry if I asked something obvious but Can you elaborate more on that virtual gpio keyboard you made? I couldn’t find anything relevant regarding the same, only thing I could find was how to simulate key press and not how to create a Virtual GPIO keyboard.

Hi @sagarsutar and Welcome to the Toradex Community!

Could you start a new Thread with providing all the information regarding your question/issue?

Thanks and best regards,
Jaski