date: 22/10/21
由于公司的安全以及其他因素,我们再开发Qt/Qml的程序是基于Ubuntu2004, 但是目标运行环境是Debian11. 为了给目标程序(后续称为app)添加屏幕键盘的支持,我们需要直接将Qt的VirtualKeyboard 添加,但是发现总是有问题。
程序运行没有问题,也不显示so的缺失,只有在点击激活键盘的时候才会出现这个错误,这就让问题很难处理。
QQmlApplicationEngine failed to load component
qrc:/main.qml:19:5: Type InputPanel unavailable
qrc:/QtQuick/VirtualKeyboard/content/InputPanel.qml:127:5: Type Keyboard unavailable
qrc:/QtQuick/VirtualKeyboard/content/components/Keyboard.qml:38:1: module "QtQuick.VirtualKeyboard.Plugins" is not installed
将`Qt/5.15.2/gcc_64/plugins/platforminputcontexts` 里面所有的库添加就解决了。
所有库的内容列表:
libcomposeplatforminputcontextplugin.so
libcomposeplatforminputcontextplugin.so.debug
libibusplatforminputcontextplugin.so
libibusplatforminputcontextplugin.so.debug
libqtvirtualkeyboardplugin.so
libqtvirtualkeyboardplugin.so.debug
QtQuick.VirtualKeyboard.Plugins module is registered by platforminputcontext plugin (QT_IM_MODULE=qtvirtualkeyboard). If that module is absent, the generic QML error reporting kicks in, and has no knowledge of root cause. How could it know, that this particular type is registered by this plugin, which needs to be loaded by the application, before creating QApplication instance?
As unfortunate as this is, IMO there is no easy fix, especially for 5.15.
However, for Qt 6, there should be changes for type QML registration at some point in future: QTBUG-92212
These changes may improve the issue.
1. https://bugreports.qt.io/browse/QTBUG-96291
2. https://github.com/sddm/sddm/issues/1290
ps: 问题的处理是同事操作的,我只是做一下记录~