卸载原来的ibus输入法框架
sudo apt-get autoremove ibus*
安装fictx输入法框架
sudo apt-get install fcitx
Ubuntu打开“语言支持“
键盘输入法系统选择fcitx,应用到整个系统
重启系统
安装搜狗输入法
下载地址:https://shurufa.sogou.com/linux
安装搜狗输入法
sudo dpkg -i sogoupinyin_4.0.1.2800_x86_64.deb
设置fcitx
只需要留下搜狗输入法即可
设置QtCreator
由于QtCreator的插件中没有支持fictx输入的插件,所以要自己手动配置
这里要区分Qt版本
确定当前使用的QtCreator是基于Qt5还是Qt6来构建的
这里是基于Qt6
Qt5
如果Qt5构建的QtCreator,可以使用apt获得编译好的fictx输入插件
sudo apt-get install libfcitx-qt5-1
搜索插件的具体路径
cocoa@ThinkPad-T14-Gen-1:~$ find /usr/lib -name "libfcitx*"
/usr/lib/x86_64-linux-gnu/libfcitx-utils.so.0
/usr/lib/x86_64-linux-gnu/libfcitx-core.so
/usr/lib/x86_64-linux-gnu/libfcitx-utils.so
/usr/lib/x86_64-linux-gnu/libfcitx-gclient.so.0.2
/usr/lib/x86_64-linux-gnu/fcitx/qt/libfcitx-quickphrase-editor5.so
/usr/lib/x86_64-linux-gnu/libfcitx-utils.so.0.1
/usr/lib/x86_64-linux-gnu/libfcitx-config.so.4.1
/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so
/usr/lib/x86_64-linux-gnu/libfcitx-config.so.4
/usr/lib/x86_64-linux-gnu/libfcitx-gclient.so
/usr/lib/x86_64-linux-gnu/libfcitx-core.so.0
/usr/lib/x86_64-linux-gnu/libfcitx-gclient.so.1
/usr/lib/x86_64-linux-gnu/libfcitx-core.so.0.3
/usr/lib/x86_64-linux-gnu/libfcitx-config.so
可以找到插件位置在
/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so
把libfcitxplatforminputcontextplugin.so拷贝到QtCreator的运行环境的插件目录
cd /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/
sudo cp libfcitxplatforminputcontextplugin.so /opt/Qt/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts/
重启QtCreator
Qt6
因为Ubuntu20.04的apt里面给出的Qt版本是5.12.8,Ubuntu22.04给出的是5.15.2,都和最新的基于Qt6的QtCreator不兼容,老板基于Qt5的QtCreator是可以直接使用的。
这时候需要自己编译fcitx-qt
获取fcitx-qt源码
fictx-qt的源码地址https://github.com/fcitx/fcitx-qt5
git clone https://github.com/fcitx/fcitx-qt5
安装Qt6开发环境
进入Qt所在目录/opt/Qt
打开MaintainceTool
添加或移除组件
选择一个LTS版本的Qt6进行安装,这里选择Qt6.2.4
安装完成后,Qt6.2.4的开发环境在/opt/Qt/6.2.4这里
编译fcitx-qt
打开cmake-gui
缺少ECM
ECM是extra-cmake-modules,可以通过apt的方式来安装
sudo apt-get install extra-cmake-modules
缺少XKBCommon
这里是需要xkbcommon的开发环境
sudo apt-get install libxkbcommon-dev
编译设置
编译Release版本
//Choose the type of build, options are: None Debug Release RelWithDebInfo
// MinSizeRel ...
CMAKE_BUILD_TYPE:STRING=Release
开启Qt5和Qt6
//Qt library
ENABLE_LIBRARY:BOOL=ON//Enable Qt5
ENABLE_QT5:BOOL=ON//Enable Qt6 im module
ENABLE_QT6:BOOL=ON
选择Qt路径,切忌不要选择apt安装的Qt5的路径
//The directory containing a CMake configuration file for Qt5Concurrent.
Qt5Concurrent_DIR:PATH=/opt/Qt/5.15.2/gcc_64/lib/cmake/Qt5Concurrent//The directory containing a CMake configuration file for Qt5Core.
Qt5Core_DIR:PATH=/opt/Qt/5.15.2/gcc_64/lib/cmake/Qt5Core//The directory containing a CMake configuration file for Qt5DBus.
Qt5DBus_DIR:PATH=/opt/Qt/5.15.2/gcc_64/lib/cmake/Qt5DBus//The directory containing a CMake configuration file for Qt5Gui.
Qt5Gui_DIR:PATH=/opt/Qt/5.15.2/gcc_64/lib/cmake/Qt5Gui//The directory containing a CMake configuration file for Qt5Widgets.
Qt5Widgets_DIR:PATH=/opt/Qt/5.15.2/gcc_64/lib/cmake/Qt5Widgets//The directory containing a CMake configuration file for Qt5.
Qt5_DIR:PATH=/opt/Qt/5.15.2/gcc_64/lib/cmake/Qt5//The directory containing a CMake configuration file for Qt6CoreTools.
Qt6CoreTools_DIR:PATH=/opt/Qt/6.2.4/gcc_64/lib/cmake/Qt6CoreTools//The directory containing a CMake configuration file for Qt6Core.
Qt6Core_DIR:PATH=/opt/Qt/6.2.4/gcc_64/lib/cmake/Qt6Core//The directory containing a CMake configuration file for Qt6DBusTools.
Qt6DBusTools_DIR:PATH=/opt/Qt/6.2.4/gcc_64/lib/cmake/Qt6DBusTools//The directory containing a CMake configuration file for Qt6DBus.
Qt6DBus_DIR:PATH=/opt/Qt/6.2.4/gcc_64/lib/cmake/Qt6DBus//The directory containing a CMake configuration file for Qt6GuiTools.
Qt6GuiTools_DIR:PATH=/opt/Qt/6.2.4/gcc_64/lib/cmake/Qt6GuiTools//The directory containing a CMake configuration file for Qt6Gui.
Qt6Gui_DIR:PATH=/opt/Qt/6.2.4/gcc_64/lib/cmake/Qt6Gui//The directory containing a CMake configuration file for Qt6.
Qt6_DIR:PATH=/opt/Qt/6.2.4/gcc_64/lib/cmake/Qt6
选择QT5 QMAKE执行程序的位置
//Location of the Qt5 qmake executable
QMAKE_EXECUTABLE:FILEPATH=/opt/Qt/5.15.2/gcc_64/bin/qmake
选择Qt插件位置
//Qt6 plugin dir
CMAKE_INSTALL_QT6PLUGINDIR:PATH=/opt/Qt/6.2.4/gcc_64/plugins//Qt5 plugin dir
CMAKE_INSTALL_QTPLUGINDIR:PATH=/opt/Qt/5.15.2/gcc_64/plugins
生成makefile后编译
cd ~/tools/fcitx-qt5/build
make -j8
把插件文件拷贝到QtCreator中
Qt5在~/tools/fcitx-qt5/build/qt5/platforminputcontext
Qt6在~/tools/fcitx-qt5/build/qt6/platforminputcontext
这个libfcitxplatforminputcontextplugin.so拷贝到QtCreator的插件目录下
/opt/Qt/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts
如果开发软件需要使用fcitx输入法,也要拷贝改插件到运行环境中加载
需要区分Qt5和Qt6
重启QtCreator