解决Qt5.6无法使用输入法输入中文

最近在ubantu上使用Qt开发进行开发,遇到不能使用输入法输入中文的问题,有点头疼,于是百度谷歌双管齐下,查阅各方资料,综合各种解决方案,kill 了这个问题,在此做下笔记,也希望能够帮助到同样遇到此问题的人。

系统版本: ubantu 16.04 LTS

输入法: 搜狗输入法

本人Qt版本: Qt5.6

解决方法,编译 fcitx-qt5 源码

 

一、解决步骤

1.1 前期准备工作

(1).安装cmake

sudo apt-get install cmake

(2) 安装 fcitx-libs-dev

sudo apt-get install fcitx-libs-dev

(3) 设置环境变量

export PATH="/home/ProgramFiles/Qt5.6.1/5.6/gcc_64/bin":$PATH

其中蓝色部分为安装Qt的位置,,这个根据个人的安装位置情况而定.

(4) 下载 fcitx-qt5 源码

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

如果显示没有权限获取,及表明没有秘钥,则可以打开这个网址直接到github上去下载压缩包,再解压即可.

1.2 执行编译操作

编译 fcitx-qt5

 cd fcitx-qt5

 cmake .

 make

 sudo make install

1.3 拷贝编译得到的 so 文件

编译成功之后,将编译得到的libfcitxplatforminputcontextplugin.so 文件拷贝到Qt的按装目录下

Tools/QtCreator/bin/plugins/platforminputcontexts 或Tools/QtCreator/lib/Qt/plugins/platforminputcontext

之中,两个目录由安装情况而定,有的会是第一个路径,有的则是第二个路径,然后再继续将这个文

件放在Qt5.6.1/5.6/gcc_64/plugins/platforminputcontexts之下 最后重启Qt或则重启电脑则可以了.

 

二、在此过程中可能遇到的问题

2.1 缺少 ECMConfig.cmake 和ecm-config.cmake

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!

下载 extra-cmake-modules_1.4.0.orig.tar.xz

链接: https://launchpad.net/ubuntu/+source/extra-cmake-modules/1.4.0-0ubuntu1

解压后进行如下操作:

cd  extra-cmake-modules-1.4.0

cmake .

sudo make install

2.2 缺少Qt5Config.cmake 和qt5-config.cmake

CMake Error at CMakeLists.txt:29 (find_package):

Could not find a package configuration file provided by "Qt5" (requested

version 5.1.0) with any of the following names:

Qt5Config.cmake

qt5-config.cmake

Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"

to a directory containing one of the above files. If "Qt5" provides a

separate development package or SDK, be sure it has been installed.

设置 CMAKE_PREFIX_PATH 环境变量

export CMAKE_PREFIX_PATH="/home/cc/ProgramFiles/Qt5.6.1/5.6/gcc_64/lib/cmake/"

 

2.3 缺少 xkbcommon

- Found PkgConfig: /usr/bin/pkg-config (found version "0.26")

-- Could NOT find XKBCommon_XKBCommon (missing: XKBCommon_XKBCommon_LIBRARY XKBCommon_XKBCommon_INCLUDE_DIR)

CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):

Could NOT find XKBCommon (missing: XKBCommon_LIBRARIES XKBCommon) (Required is at least version "0.5.0")

进行安装即可.

sudo apt-get install libxkcommon-dev 

编译:

sudo apt-get install bison

./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --disable-x11

make

sudo make install

 

三、其他参考资料

(1)  http://my.oschina.net/lieefu/blog/505363

(2) http://www.gszadc.com/448428224.html

(3) http://www.07net01.com/2016/06/1558676.html

 

 

 

 

 

 

 

  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值