彻底解决Ubuntu下qt creator无法显示中文问题

彻底解决Ubuntu下qt creator无法显示中文问题

在Ubuntu 16.04系统下面装好QT5.4(32位)之后,在写代码想注释的时候,发现不能写入中文,下面是我解决的方法.

1. 安装 fcitx-frontend-qt5

sudo apt-get install fcitx-frontend-qt5

2. 将安装之后的 fcitx-frontend-qt5复制到指定的目录

我们可以通过在命令行下输入

dpkg -L fcitx-frontend-qt5

来查看安装之后的路径,一般都是在:
/usr/lib/i386-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so

将上面的文件复制到qt的安装目录中去,需要复制到下面两个目录,复制过去之后,名字不能变:

qt安装目录/Tools/QtCreator/bin/plugins/platforminputcontexts/
qt安装目录/5.4/gcc/plugins/platforminputcontexts/

提醒:每个人qt的安装目录是不一样的,我的是/opt因此我就要复制到下面这两个目录:
/opt/Tools/QtCreator/bin/plugins/platforminputcontexts/
/opt/5.4/gcc/plugins/platforminputcontexts/

3. 修改配置文件

把/etc/X11/xinit/xinput.d/fcitx下的fcitx文件用gedit打开修改如下(我的是32位的QT)

修改前如下:

XIM=fcitx
XIM_PROGRAM=/usr/bin/fcitx
XIM_ARGS=""
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
DEPENDS="fcitx"

修改后如下:

扫描二维码关注公众号,回复: 3725095 查看本文章
XIM=fcitx
XIM_PROGRAM=/usr/bin/fcitx
XIM_ARGS="-xim"
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
DEPENDS="fcitx,fcitx-frontend-qt5"

4. 重启系统

打开QT就会发现可以输入中文了.

猜你喜欢

转载自blog.csdn.net/healingwounds/article/details/78600105