彻底解决ubuntu环境下,Qt5.5以上版本无法进行中文注释的问题。
来源:互联网 发布:中老年人运动装淘宝网 编辑:程序博客网 时间:2024/05/20 23:35
**声明:测试的系统环境为ubuntu14.04/ubuntu16.04
测试qt的版本有:qt5.6.0/qt5.7.0
方法通过测试,qt可以正常输入中文注释。**
1. 安装fcitx-frontend-qt5,很重要,很多教程里面没有这个,导致无法正常输入中文注释。笔者在这里纠结了好久,不管这个有没有效,建议安装。
sudo apt-get install fcitx-frontend-qt5
2. 安装CMake,由于后面编译文件的时候,对CMake有具体要求,因此在前面的时候直接将cmake升级到3.0以上。 在这里不建议采用源码编译的方式进行,至于为什么,那是因为太费事了。笔者一步一坑走过来的。建议直接更新源升级即可。
sudo apt-get install software-properties-commonsudo add-apt-repository ppa:george-edison55/cmake-3.xsudo apt-get updatesudo apt-get install cmake
3. 安装 fcitx-libs-dev
sudo apt-get install fcitx-libs-dev
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.cmakeecm-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.xzcd extra-cmake-modules-1.4.0cmake .makesudo make install
注意:注意:注意:重要事情说三遍,在安装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.cmakeqt5linguisttools-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
解决方法如下:
设置 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,为了避免麻烦的话,直接在命令行输入这一行就好了。
5. 安装xkbcommon
到 http://xkbcommon.org/ 下载最新版的 xkbcommon解压后,sudo apt-get install bison./configure --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --disable-x11makesudo make install
6. 下载fcitx-libs 源码并编译安装,具体步骤如下
首先确定你的Qt的安装目录,我这里是~/Qt5.7.0/,你的或者可能在/home/<用户名>/Qt5.7.0/
export PATH="/5.7/gcc_64/bin":$PATH
下载fcitx-libs源码
git clone https://github.com/fcitx/fcitx-qt5
如果这里提示木有git,下载安装一个即可。
sudo apt-get install git
下载源码解压后按照以下步骤编译
cd fcitx-qt5cmake .(这里是有个点的,一定要记住哦)make sudo make install
**7. 将编译好的libfcitxplatforminputcontextplugin.so文件分别拷贝到Tools/QtCreator/lib/Qt/plugins/platforminputcontexts。和 Qt5.7.0/5.7/GCC_64/plugins/platforminputcontexts并且将两个文件的权限提上去。
chmod +x 文件路劲/文件名
笔者这两个文件中, 这个Qt5.7.0/5.7/GCC_64/plugins/platforminputcontexts文件下的文件是带锁的,此时需要解锁,然后进行替换。
sudo chmod 777 /文件路径/文件名
8. 配置系统环境
echo 'export XMODIFIERS=@im=fcitx' >> .bashrc echo 'export QT_IM_MODULE=fcitx' >> .bashrc
最好确认下是否配置好,笔者就碰到过没有配置成功的情况。
sudo gedit .bashrc
9. 关机重启。请记住,一定要关机重启,避免不能输入中文。
10. 建议大家可以下载我编译的文件,然后按照步骤1、步骤7、8、9尝试一下,笔者并没有尝试,但从理论上来说是可以拷贝并生效的。
下载地址:
备注:笔者默认大家都是装了搜狗输入法的,如果没装,请参照搜狗官网即可。在这里就不加赘述了。
- 彻底解决ubuntu环境下,Qt5.5以上版本无法进行中文注释的问题。
- 彻底解决Ubuntu下qt creator无法显示中文问题
- ubuntu环境下 python 3.0以上版本对sqlite3的支持问题
- Ubuntu中Netbeans的中文问题彻底解决
- ubuntu彻底解决wine的中文问题
- qt5版本的中文显示问题
- Ubuntu Linux平台下Python集成开发环境Wing IDE无法输入中文的问题
- 在ubuntu得linux环境下安装jdk7以上版本
- 解决Qt5.2及以上版本无法连接64位mysql问题
- 彻底解决ubuntu 16.04 LTS不能输入中文的问题
- VC2010下Qt5的中文乱码问题
- VC2010下Qt5的中文乱码问题
- VC2010下Qt5的中文乱码问题
- 关于linux下Qt5.7.0安装中文输入法无法显示的问题
- Tomcat下中文的彻底解决
- Tomcat下中文的彻底解决
- tomcat下中文的彻底解决
- tomcat下中文的彻底解决
- 浅谈angular架构(上)
- oracle 基础01
- source1.6中不支持multi-catch语句} catch (InterruptedException | ExecutionException e) {
- React Native 笔记
- ES6-对象的扩展-super关键字
- 彻底解决ubuntu环境下,Qt5.5以上版本无法进行中文注释的问题。
- PHP 与 Java 的区别
- 求2个或3个正整数中的最大值,用带有默认参数的函数实现
- [leetcode]#69. Sqrt(x)
- RPC入门总结(四)RPC IO基础:Netty原理和使用
- CentOS JDK安装
- OpenLayers4文本上图实例
- 在Windows中安装一台Linux虚拟机
- Java细节与规范:HashMap扩容-ReSize