QT Global Keyboard not working X11
-
Hi, we are developing with an IMX6 processor for which we built a custom linux image using buildroot. QT 5.10 was also installed from source to a custom location on an SD card. An application compiled against our QT image works correctly except clicking on a text box does not cause the QT keyboard to popup in a separate window. We have tried setting the QT_IM_MODULE environment variable to "qtvirtualkeyboard" by both methods but neither works:
1.) Before executing our binary we run export QT_IM_MODULE=qtvirtualkeyboard
2.) Inside of the applications main we set it explicitly via qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));The plugin does exist, and we are able to get it working when it is embedded in our QML files by adding the following line to the pro file
static{ QT += svg QTPLUGIN += qtvirtualkeyboardplugin }
And implementing the input panel in our QML as below:
import QtQuick.VirtualKeyboard 2.0 import QtQuick.VirtualKeyboard.Settings 2.0 ... InputPanel{ id: inputPanel height: 350 anchors{ left: parent.left right: parent.right bottom: parent.bottom } visible: true }
However we need the keyboard to be the same across several applications (not all written with QML) and would like the standalone keyboard to work. Is there some way to start debugging why the keyboard does not show up? I made a test application with a text box in it and when I launch the application with export QT_LOGGING_RULES="qt.virtualkeyboard=true" I do see events when the text box gets focus:
qt.virtualkeyboard: PlatformInputContext::commit() qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImInputItemClipRectangle) qt.virtualkeyboard: PlatformInputContext::showInputPanel() qt.virtualkeyboard: PlatformInputContext::setFocusObject(): TextInputWithHandles_QMLTYPE_54(0x6dbfe8) qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImQueryAll)
It appears the plugin is loading correctly as when I run with QT_DEBUG_PLUGINS=1 I do not get any errors
... Got keys from plugin meta data ("compose", "xim") QFactoryLoader::QFactoryLoader() looking at "/sandbox/qt-arm-5.10/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so" Found metadata in lib /sandbox/qt-arm-5.10/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so, metadata= { "IID": "org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1", "MetaData": { "Keys": [ "ibus" ] }, "className": "QIbusPlatformInputContextPlugin", "debug": false, "version": 330240 } Got keys from plugin meta data ("ibus") QFactoryLoader::QFactoryLoader() looking at "/sandbox/qt-arm-5.10/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.so" Found metadata in lib /sandbox/qt-arm-5.10/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.so, metadata= { "IID": "org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1", "MetaData": { "Keys": [ "qtvirtualkeyboard" ] }, "className": "QVirtualKeyboardPlugin", "debug": false, "version": 330240 } Got keys from plugin meta data ("qtvirtualkeyboard") QFactoryLoader::QFactoryLoader() checking directory path "/sandbox/bin/platforminputcontexts" ... loaded library "/sandbox/qt-arm-5.10/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.so" QFactoryLoader::QFactoryLoader() checking directory path "/sandbox/qt-arm-5.10/plugins/generic" ... QFactoryLoader::QFactoryLoader() looking at "/sandbox/qt-arm-5.10/plugins/generic/libqevdevkeyboardplugin.so" Found metadata in lib /sandbox/qt-arm-5.10/plugins/generic/libqevdevkeyboardplugin.so, metadata= { "IID": "org.qt-project.Qt.QGenericPluginFactoryInterface", "MetaData": { "Keys": [ "EvdevKeyboard" ] }, "className": "QEvdevKeyboardPlugin", "debug": false, "version": 330240 } Got keys from plugin meta data ("evdevkeyboard") QFactoryLoader::QFactoryLoader() looking at "/sandbox/qt-arm-5.10/plugins/generic/libqevdevmouseplugin.so" Found metadata in lib /sandbox/qt-arm-5.10/plugins/generic/libqevdevmouseplugin.so, metadata= { "IID": "org.qt-project.Qt.QGenericPluginFactoryInterface", "MetaData": { "Keys": [ "EvdevMouse" ] }, "className": "QEvdevMousePlugin", "debug": false, "version": 330240 } ...
I am using qtvirtualkeyboard-deployment-guide to try to get this working with no luck. Perhaps we are missing some X11 library that catches events or something?
-
I have dug awful deep on this one. The issue seems to be when you are cross compiling you can't use the desktop qt keyboard at all, which is odd because it works find when you embed it. The section of source code causing the issue is found in QT_DIR/qtvirtualkeyboard/src/virtualkeyboard/virtualkeyboard.pro. The issue is with the section below. When cross compiling the CROSS_COMPILE variable is not empty and hence the define is never set and additional source files are excluded from the build.
!disable-desktop:isEmpty(CROSS_COMPILE):!android-embedded:!qnx { SOURCES += desktopinputpanel.cpp inputview.cpp HEADERS += desktopinputpanel_p.h inputview_p.h DEFINES += QT_VIRTUALKEYBOARD_DESKTOP !no-pkg-config:packagesExist(xcb) { PKGCONFIG += xcb xcb-xfixes DEFINES += QT_VIRTUALKEYBOARD_HAVE_XCB } }
We need "QT_VIRTUALKEYBOARD_DESKTOP" to be defined because this causes the "QT_DIR/qtvirtualkeyboard/src/virtualkeyboard/platforminputcontext.cpp" file to execute the code that launches the QT keyboard in a separate desktop window. The section of relevant code is in "void PlatformInputContext::update(Qt::InputMethodQueries queries)".
#ifdef QT_VIRTUALKEYBOARD_DESKTOP if (enabled && !m_inputPanel) { m_inputPanel = new DesktopInputPanel(this); m_inputPanel->createView(); m_selectionControl = new DesktopInputSelectionControl(this, m_inputContext); m_selectionControl->createHandles(); } #endif
Is there any patch or workaround? I manually removed the check for cross compiling and the keyboard now shows up when I click in a text field. Unfortunately it fully takes up the screen and sometimes locks up entirely. I will try a clean build without the cross compile check in the pro file and see if that works any better.
-
Doing a full rebuild of the QT source with a patch to remove the check for CROSS-COMPILE in the pro file results in the same locking up behaviour and black background. I also am pulling the source code for the QT keyboard plugin from official source and checked out the branch relevant to my version of QT (5.10). See https://code.qt.io/cgit/qt/qtvirtualkeyboard.git/