c++ - Qt 虚拟键盘和 QInputContextFactory

标签 c++ qt qt4 user-input virtual-keyboard

我为我的 Ubuntu 桌面构建了 Maliit (https://wiki.maliit.org/Main_Page) 虚拟屏幕键盘,它与附带的示例应用程序配合得很好。我还能够制作自己的简单 Qt 示例应用程序,当小部件获得焦点时,该应用程序将显示键盘。

我现在正在尝试将虚拟键盘部署到带有触摸屏的目标板上运行的嵌入式 Linux 系统。目标板上没有安装 X11,我使用 QWS (-qws) 运行了不少 Qt 应用程序。

Maliit 架构 ( http://maliit.org/doc/framework/latest/architecture.html ) 需要服务器实例与应用程序通信,并且应用程序使用 QApplication::setInputContext 设置其输入上下文。

在 Ubuntu 上我只是这样做:

export QT_IM_MODULE=Maliit
maliit-server -software &
maliit-exampleapp-plainqt

键盘出现并且一切正常(假设我有 X11)!

在嵌入式板上,我在一个 SSH session 中执行以下操作:

export QT_IM_MODULE=Maliit
dbus-launch --auto-syntax maliit-server -software -qws

然后是另一个 SSH session :

export QT_IM_MODULE=Maliit
source /find_dbus_address.sh
echo $DBUS_SESSION_BUS_ADDRESS
maliit-exampleapp-plainqt -qws

但我总是收到错误:

QApplication::setInputContext: called with 0 input context

这意味着示例应用程序在 main 中的以下行失败:

// Workaround for lighthouse Qt
kit.setInputContext(QInputContextFactory::create("Maliit", &kit));

嵌入式板上“ps”命令的输出显示如下:

  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

所以服务器并不像 Ubuntu 中那样主动运行......而是处于“可中断 sleep ”状态。在此状态下鼠标确实会移动。我仍然收到 0 输入上下文错误。

这里有一个错误 --> https://bugs.maliit.org/show_bug.cgi?id=185声称 QWS 与 Maliit 正在为他工作,至少他可以看到输入..

还有一种 Maliit 模式据说可以绕过 DBUS(请参见此处 --> http://www.jonnor.com/2012/03/ ),但我仍然收到“0 输入上下文”错误:

所以我尝试在我的嵌入式板上做:

export QT_IM_MODULE=MaliitDirect ; echo $QT_IM_MODULE ; maliit-exampleapp-embedded -qws

并且始终接收:

QApplication::setInputContext: called with 0 input context
Unable to embedded Maliit input method widget

我在 Ubuntu 12.04 桌面上构建了 Qt 4.8.2 Embedded,可以使用 -qws 启动 Maliit 服务器以及示例应用程序,并且可以使用 QWS 看到虚拟键盘工作得很好。我正在为插件和 maliit 框架使用 git 存储库的最新克隆。

我的问题是在目标上运行为我的 ARM 板编译的相同 Maliit 服务器和示例应用程序。我不断收到错误 QApplication::setInputContext: Called with 0 input context.

我使用 DBUS dbus-monitor 工具进行了一些监控。我最初向我的主板打开了 1 个 SSH session ,并运行 eval dbus-launch --auto-syntax 并复制了 DBUS_SESSION_BUS。然后我打开了 2 个新的 SSH session 。

在我做的第一个中:

$ export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-vVNCW9zP7e,guid=75ecd72645dfb9b4358048db506dfec
$ export QT_IM_MODULE=Maliit
$ maliit-server -software -qws

在第二个中我做了:

$ export DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-vVNCW9zP7e,guid=75ecd72645dfb9b4358048db506dfecb
$ export QT_IM_MODULE=Maliit
$ maliit-exampleapp-settings -qws

但是,我立即面临:

[9;0]QApplication::setInputContext: called with 0 input context
SettingsWidget::connected()
SettingsWidget::pluginSettingsReceived()
Setting layout QVariant(QString, "nemo-keyboard.qml:")

在 dbus-monitor shell 中我看到:

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"

有人知道这里发生了什么吗? DBUS 是否与 QInputContextFactory 失败有关?我能否以某种方式获得有关失败原因以及无法设置输入上下文的更多信息?

感谢您的帮助 -

最佳答案

难以置信,如此简单的修复。只需像这样设置 QT_PLUGIN_PATH:

export QT_PLUGIN_PATH=/home/user/plugins

关于c++ - Qt 虚拟键盘和 QInputContextFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12647279/

相关文章:

c++ - 使用CMake和Make编译时OpenCV库错误: cannot find -lopencv_bgsegm

c++ - 基于范围的 for 循环会抛出带有数组参数的编译器错误

C++更改构造函数中的函数解析优先级

c++ - 什么时候删除 QNetworkAccessManager 指针?

c++ - 发布版本的应用程序抛出 c1083 无法打开包含文件错误

C++递归传递QDomDocument指针

qt - 如何将 qundo 命令保存到文件并重新加载它?

c++ - 如何在 Qt 中将 tiff 或 pnm 转换为 jpeg

linux - 如何使用应用程序部署 Qt 库?

c++ - Qt 4 Sqlite,QDataWidgetMapper 问题