2017.8.1更新支持Qt5.9.1,需要重做步骤4,编译fcitx-qt5。
Ubuntu 14.04安装QT5.6.1后,发现creator里面输入不了中文。ibus原来是可以输入的,但装了搜狗输入法后,悲剧的事情发生了,iBus与fcitx都输入不了中文。
网上参考了这篇文章:http://blog.csdn.net/liang101x/article/details/51956436 ,有个别步骤不一样,特总结一下。
1. 安装依赖库
sudo apt-get install cmake fcitx-libs-dev libgl1-mesa-dev libglu1-mesa-dev libxkbcommon-devbison
2. 设置Qt环境变量
export PATH="~/Qt5.6.1/5.6/gcc_64/bin":$PATH
3. 下载fcitx-qt5的源码
git clone https://github.com/fcitx/fcitx-qt5
4. 编译
进入fcitx-qt5目录
cd fcitx-qt5
cmake .
make
sudo make install
cp /home/volfull/Qt5.9.1_Computer/5.9.1/gcc_64/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so ~/Qt5.9.1_Computer/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts
将libfcitxplatforminputcontextplugin.so拷贝到Qt5.9.1_Computer/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts下面。
cmake . 时这里会出错如下几种错误,需要分别解决:
(1)
CMake Error at CMakeLists.txt:8 (find_package):
Could not find a package configuration file provided by "ECM" (requested
version 1.4.0) with any of the following names:
ECMConfig.cmake
ecm-config.cmake
Add the installation prefix of "ECM" to CMAKE_PREFIX_PATH or set "ECM_DIR"
to a directory containing one of the above files. If "ECM" provides a
separate development package or SDK, be sure it has been installed.
-- Configuring incomplete, errors occurred!
[解决方法]
进入这个页面https://launchpad.net/ubuntu/+source/extra-cmake-modules/1.4.0-0ubuntu1
下载extra-cmake-modules_1.4.0.orig.tar.xz
进入这个页面 https://launchpad.net/ubuntu/+source/extra-cmake-modules/5.18.0-0ubuntu1
下载extra-cmake-modules_5.18.0.orig.tar.xz
各自解压后
cd各自目录
cmake .
make
sudo make install
(2)
Could NOT find XKBCommon (missing: XKBCommon_LIBRARIES XKBCommon) (Required is at least version "0.5.0")
[解决方法]
wget http://xkbcommon.org/download/libxkbcommon-0.5.0.tar.xz (这里出现网址打不开,我用迅雷离线下载可以下。)
tar xf libxkbcommon-0.5.0.tar.xz
cd 目录
./configure -prefix=/usr -libdir=/usr/lib/x86_64-linux-gnu -disable-x11
make
sudo make install
(3)
已经安装libxkbcommon.so, 但还是报错(版本低)
Could NOT find XKBCommon: Found unsuitable version "0.4.1", but required is
at least "0.5.0" (found /usr/lib/x86_64-linux-gnu/libxkbcommon.so)
[解决方法]
在fcitx-qt5目录里面,修改CMakeCache.txt 文件:(强行修改当前检测到的版本到 0.5.0)
PKG_XKBCommon_XKBCommon_VERSION:INTERNAL=0.5.0
5.修改profile文件
在 ~/.profile 文件末尾添加:
GTK_IM_MODULE=fcitx
export XIM_PROGRAM=fcitx
export XIM=fcitx
export QT_IM_MODULE=fcitx
export GTK_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
6. 重起系统,运行QT,发现可以用搜狗输入法输入中文了!
效果如图: