Qt Virtual Keyboard and QInputContextFactory
-
04-07-2021 - |
Pergunta
I built the Maliit (https://wiki.maliit.org/Main_Page) virtual on-screen keyboard for my Ubuntu desktop and it works just fine with the included example apps. I was also able to make my own simple Qt example app that would show the keyboard when a widget assumed focus.
I am now trying to deploy the virtual keyboard to an embedded Linux system running on my target board with a touchscreen. There is no X11 installed on the target board and I run quite a few Qt Apps with QWS ( -qws ).
Maliit architecture ( http://maliit.org/doc/framework/latest/architecture.html ) requires a server instance to communicate with an application and the application sets it's input context using QApplication::setInputContext.
On Ubuntu I simply do:
export QT_IM_MODULE=Maliit
maliit-server -software &
maliit-exampleapp-plainqt
And the keyboard appears and everything works ( granted I have X11 )!
On the embedded board I do in one SSH session:
export QT_IM_MODULE=Maliit
dbus-launch --auto-syntax maliit-server -software -qws
And then another SSH session:
export QT_IM_MODULE=Maliit
source /find_dbus_address.sh
echo $DBUS_SESSION_BUS_ADDRESS
maliit-exampleapp-plainqt -qws
But I always get the error:
QApplication::setInputContext: called with 0 input context
Which means that the example app is failing in main at the following line:
// Workaround for lighthouse Qt
kit.setInputContext(QInputContextFactory::create("Maliit", &kit));
The output of the 'ps' command on the embedded board shows the following:
191 user 1692 S -sh
192 user 39608 S maliit-server -software -qws
196 user 2092 S /usr/bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session
201 user 1692 R ps
So the server is not actively running like it is in Ubuntu... but in an 'interruptable sleep' state. The mouse does move in this state. I still get the 0 input context error.
There is a bug here --> https://bugs.maliit.org/show_bug.cgi?id=185 that claims QWS with Maliit is working for him, at least he can see input..
There is also a mode of Maliit that supposedly bypasses DBUS ( see here --> http://www.jonnor.com/2012/03/ ) and with that I still get '0 input context' errors:
So I tried doing on my embedded board:
export QT_IM_MODULE=MaliitDirect ; echo $QT_IM_MODULE ; maliit-exampleapp-embedded -qws
And always receiving:
QApplication::setInputContext: called with 0 input context
Unable to embedded Maliit input method widget
I built Qt 4.8.2 Embedded on Ubuntu 12.04 Desktop and can launch the maliit-server with -qws as well as the example apps and can see the virtual keyboard working just fine using QWS. I am using the latest clone for the git repo for both the plugins and maliit-framework.
My problem is running same maliit-server and example app compiled for my ARM board on the target. I constantly get the error QApplication::setInputContext: called with 0 input context.
I did some monitoring with the DBUS dbus-monitor tool. I initially opened 1 SSH session to my board and ran eval dbus-launch --auto-syntax
and copied the DBUS_SESSION_BUS. I then opened 2 new SSH sessions.
In the first one I did:
$ export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-vVNCW9zP7e,guid=75ecd72645dfb9b4358048db506dfec
$ export QT_IM_MODULE=Maliit
$ maliit-server -software -qws
In the second one I did:
$ export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-vVNCW9zP7e,guid=75ecd72645dfb9b4358048db506dfecb
$ export QT_IM_MODULE=Maliit
$ maliit-exampleapp-settings -qws
However, I am immediately faced with:
[9;0]QApplication::setInputContext: called with 0 input context
SettingsWidget::connected()
SettingsWidget::pluginSettingsReceived()
Setting layout QVariant(QString, "nemo-keyboard.qml:")
And in the dbus-monitor shell I see:
desktop.DBus; member=NameOwnerChanged
string ":1.6"
string ""
string ":1.6"
method call sender=:1.6 -> dest=org.freedesktop.DBus serial=1 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=Hello
signal sender=org.freedesktop.DBus -> dest=(null destination) serial=8 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
string "org.maliit.server"
string ""
string ":1.6"
method call sender=:1.6 -> dest=org.freedesktop.DBus serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=RequestName
string "org.maliit.server"
uint32 4
signal sender=org.freedesktop.DBus -> dest=(null destination) serial=9 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
string ":1.7"
string ""
string ":1.7"
method call sender=:1.7 -> dest=org.freedesktop.DBus serial=1 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=Hello
method call sender=:1.7 -> dest=org.maliit.server serial=2 path=/org/maliit/server/address; interface=org.freedesktop.DBus.Properties; member=Get
string "org.maliit.Server.Address"
string "address"
method return sender=:1.6 -> dest=:1.7 reply_serial=2
variant string "unix:abstract=/tmp/maliit-server/dbus-CPgFHrxwAi,guid=dfc1dfc367a647e36e6e4c3c506e00db"
Does anyone have an idea on what is going on here? Could DBUS have something to do with the QInputContextFactory failing? Can I somehow get more information on what is failing and why I can't set my input context?
Thank you for your help -
Solução
Unbelievable, such a simple fix. Simply set the QT_PLUGIN_PATH like so:
export QT_PLUGIN_PATH=/home/user/plugins