fcitx/fcitx5-qt

静态导入 无法切换输入法

xmn-001 opened this issue · 7 comments

编译方式
cmake -DENABLE_QT4=Off -DBUILD_ONLY_PLUGIN=On -DBUILD_STATIC_PLUGIN=On .
生成了静态的.a文件

新建qt测试项目

导入头文件
#include
Q_IMPORT_PLUGIN(QComposePlatformInputContextPlugin)
Q_IMPORT_PLUGIN(QIbusPlatformInputContextPlugin)
Q_IMPORT_PLUGIN(QFcitx5PlatformInputContextPlugin)

pro增加依赖
LIBS += /opt/github/fcitx5-qt/qt5/platforminputcontext/libfcitx5platforminputcontextplugin.a
LIBS += /opt/github/fcitx5-qt/qt5/dbusaddons/libFcitx5Qt5DBusAddons.a

在ui中增加文本输入框。编译链接后:
1:无法正常切换输入法
2:手动切换到谷歌拼音,也无法正常输入中文。

你还是得设置环境变量 QT_IM_MODULE=fcitx 推测就是单纯环境变量不对。另外这个方式我测试过了没有问题

另外你可以 QT_DEBUG_PLUGINS=1 看看具体加载情况

1:测试的是谷歌拼音输入法
2:在终端Terminal是正常切换输入谷歌拼音,也可以正常输入
3:启动qt的demo方式
QT_IM_MODULE=fcitx QT_DEBUG_PLUGINS=1 ./test-demo
4:vim test-demo 在里面能够找到关键字:fcitx5 ,x!QFcitx5PlatformInputContextPlugin

还是无法在test-demo里面输入中文,以及切换输入法。

1:环境 Ubuntu 16.04
2:静态编译Qt 5.15.1

QT_IM_MODULE=fcitx QT_DEBUG_PLUGINS=1 ./test-demo
以下是日志:
QFactoryLoader::QFactoryLoader() ignoring "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3" since plugins are disabled in static builds
loaded library "Xcursor"
QFactoryLoader::QFactoryLoader() ignoring "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1" since plugins are disabled in static builds
QFactoryLoader::QFactoryLoader() ignoring "org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1" since plugins are disabled in static builds
loaded library "libdbus-1"
QFactoryLoader::QFactoryLoader() ignoring "org.qt-project.Qt.QStyleFactoryInterface" since plugins are disabled in static builds
QFactoryLoader::QFactoryLoader() ignoring "org.qt-project.Qt.QPA.Xcb.QXcbGlIntegrationFactoryInterface.5.5" since plugins are disabled in static builds
QFactoryLoader::QFactoryLoader() ignoring "org.qt-project.Qt.QIconEngineFactoryInterface" since plugins are disabled in static builds
QFactoryLoader::QFactoryLoader() ignoring "org.qt-project.Qt.QImageIOHandlerFactoryInterface" since plugins are disabled in static builds
QFactoryLoader::QFactoryLoader() ignoring "org.qt-project.Qt.QAccessibleFactoryInterface" since plugins are disabled in static builds

看起来至少得20.04的fcitx才能用fcitx5-qt

Ubuntu 16.04
1:因为glic的版本偏低,可以适配大多数的其他linux系统
2:fcitx -v 返回的是4.2.9.1
3: sudo apt search fcitx 返回的相关版本都是4.2.9.1

按照这么说,是不是判死刑了?

你可以编 fcitx-qt5的静态版,虽然里面没写选项,其实只需要把shared改成static