Ubuntu下Qt不支持搜狗输入法解决方法

**声明:测试的系统环境为ubuntu14.04/ubuntu16.04
测试qt的版本有:qt5.6.0/qt5.7.0/qt5.9.1
方法通过测试,qt可以正常输入中文注释。**

1. 安装fcitx-frontend-qt5,很重要,很多教程里面没有这个,导致无法正常输入中文注释。笔者在这里纠结了好久,不管这个有没有效,建议安装。

sudo apt-get install fcitx-frontend-qt5
   
   
  • 1

2. 安装CMake,由于后面编译文件的时候,对CMake有具体要求,因此在前面的时候直接将cmake升级到3.0以上。 在这里不建议采用源码编译的方式进行,至于为什么,那是因为太费事了。笔者一步一坑走过来的。建议直接更新源升级即可。

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:george-edison55/cmake-3.x
sudo apt-get update
sudo apt-get install cmake
   
   
  • 1
  • 2
  • 3
  • 4

3. 安装 fcitx-libs-dev

sudo apt-get install fcitx-libs-dev
   
   
  • 1

4. 安装extra-cmake-modules_1.4.0,由于在编译fcitx-qt5 源码时会报错。错误提示如下

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!
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

解决方法如下:

到这个页面 https://launchpad.net/ubuntu/+source/extra-cmake-modules/1.4.0-0ubuntu1 下载 extra-cmake-modules_1.4.0.orig.tar.xz
cd extra-cmake-modules-1.4.0
cmake .
make
sudo make install
   
   
  • 1
  • 2
  • 3
  • 4
  • 5

注意:注意:注意:重要事情说三遍,在安装extra-cmake-modules_1.4.0如果提示一下错误,那边并没有安装成功。

~/Downloads/extra-cmake-modules-1.4.0$ cmake .
CMake Warning at tests/CMakeLists.txt:28 (find_package):
  Could not find a package configuration file provided by "Qt5LinguistTools"
  with any of the following names:
Qt5LinguistToolsConfig.cmake
qt5linguisttools-config.cmake
  Add the installation prefix of "Qt5LinguistTools" to CMAKE_PREFIX_PATH or
  set "Qt5LinguistTools_DIR" to a directory containing one of the above
  files.  If "Qt5LinguistTools" provides a separate development package or
  SDK, be sure it has been installed.
-- Looking for Sphinx Documentation Builder...
-- Sphinx Documentation Builder not found - documentation will not be built (see http://sphinx-doc.org/)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cposture/Downloads/extra-cmake-modules-1.4.0
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

解决方法如下:

设置 CMAKE_PREFIX_PATH 环境变量 为 qtbase 目录(<Qt安装目录>/5.7/Src/qtbase/),我这里为:
export CMAKE_PREFIX_PATH="~/Qt5.7.0/5.7/Src/qtbase/"
如果还是不行,则修改为
export CMAKE_PREFIX_PATH="/安装路径/Qt5.7.0/5.7/gcc_64/lib/cmake/"export PATH="/安装路径/Qt5.7.0/5.7/gcc_64/bin":$PATH,为了避免麻烦的话,直接在命令行输入这一行就好了。
   
   
  • 1
  • 2
  • 3
  • 4
  • 5

5. 安装xkbcommon

到 http://xkbcommon.org/ 下载最新版的 xkbcommon
解压后,
sudo apt-get install bison
./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --disable-x11
make
sudo make install
   
   
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

补充一点:如果在安装的时候一是缺少OpenGL的头文件,可以安装一下以下的库

sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev
   
   
  • 1

6. 下载fcitx-libs 源码并编译安装,具体步骤如下

首先确定你的Qt的安装目录,我这里是~/Qt5.7.0/,你的或者可能在/home/<用户名>/Qt5.7.0/

export PATH="/5.7/gcc_64/bin":$PATH
   
   
  • 1

下载fcitx-libs源码

git clone https://github.com/fcitx/fcitx-qt5
   
   
  • 1

如果这里提示木有git,下载安装一个即可。

sudo apt-get install git
   
   
  • 1

下载源码解压后按照以下步骤编译

cd fcitx-qt5
cmake .(这里是有个点的,一定要记住哦)
make 
sudo make install
   
   
  • 1
  • 2
  • 3
  • 4

**7. 将编译好的libfcitxplatforminputcontextplugin.so文件分别拷贝到Tools/QtCreator/lib/Qt/plugins/platforminputcontexts。和 Qt5.7.0/5.7/GCC_64/plugins/platforminputcontexts并且将两个文件的权限提上去。

chmod +x 文件路劲/文件名
   
   
  • 1

笔者这两个文件中, 这个Qt5.7.0/5.7/GCC_64/plugins/platforminputcontexts文件下的文件是带锁的,此时需要解锁,然后进行替换。

sudo chmod 777 /文件路径/文件名
   
   
  • 1

8. 配置系统环境

echo 'export XMODIFIERS=@im=fcitx' >> .bashrc 
echo 'export QT_IM_MODULE=fcitx' >> .bashrc
   
   
  • 1
  • 2

最好确认下是否配置好,笔者就碰到过没有配置成功的情况。

sudo gedit .bashrc 
   
   
  • 1

9. 关机重启。请记住,一定要关机重启,避免不能输入中文。

10. 建议大家可以下载我编译的文件,然后按照步骤1、步骤7、8、9尝试一下,笔者并没有尝试,但从理论上来说是可以拷贝并生效的。

下载地址:

备注:笔者默认大家都是装了搜狗输入法的,如果没装,请参照搜狗官网即可。在这里就不加赘述了。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值