• 最全解决Qt5无法输入中文的问题


    参考博客:

    https://www.cnblogs.com/liuxuzzz/p/6409294.html

    https://my.oschina.net/lieefu/blog/505363?p=%7B%7BcurrentPage%201%7D%7D

    Qt5.3及以前的版本:

    qt creator插件目录:qt安装目录/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts

    需要的fcitx输入法插件文件:libfcitxplatforminputcontextplugin.so

    解决方法:

    使用dpkg查找插件文件,fcitx在fcitx-frontend-qt5中,没有就用apt安装即可。

    $ dpkg -L fcitx-frontend-qt5 | grep .so
    
    /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so

    然后复制这个文件到QT Creator目录:

    $ cd qt安装目录/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts/
    $ cp /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so .
    $ chmod +x libfcitxplatforminputcontextplugin.so

    然后重启QT Creator即可输入中文。

    ---------------------------------------------------------------

    编译程序后程序无法输入中文问题,也是缺少插件的原因。

    $ cd QT安装目录/5.8/gcc_64/plugins/platforminputcontexts
    $ cp /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so .
    $ chmod +x libfcitxplatforminputcontextplugin.so

    然后重新编译即可。

    Qt5.3以上的版本:

        Qt5.4以及Qt5.5,旧办法失效,原因是Qt5.4后对之前Qt5版本不再二进制兼容,libfcitxplatforminputcontextplugin.so 需要编译最新的fcitx-qt5。

    编译fcitx-qt需要cmake,安装cmake命令,如果已经安装,请略过。

    sudo apt-get install cmake
    • 安装 fcitx-libs-dev

    sudo apt-get install fcitx-libs-dev
    • 设置qmake的环境变量:

    export PATH="/home/lieefu/Qt5.9.0/5.9/gcc_64/bin":$PATH
    
    • 下载fcitx-libs源码:

    git clone git@github.com:fcitx/fcitx-qt5.git
    • 编译方法:

    cd fcitx-qt5
    cmake .
    make
    sudo make install

    最后把编译得到 libfcitxplatforminputcontextplugin.so 拷贝到 Qt5.5安装目录的 Tools/QtCreator/bin/plugins/platforminputcontexts

    Qt5.6的目录是 Tools/QtCreator/lib/Qt/plugins/platforminputcontexts

    大功告成!

    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 extra-cmake-modules-1.4.0
    cmake .
    make
    sudo make install

    CMake Error at /home/lieefu/Qt5.5.0/5.5/gcc_64/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:9 (message):

      Failed to find "GL/gl.h" in "/usr/include/libdrm".

    处里方法:

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

    -- 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")

    处里方法:

    Ubuntu 16.04中可以执行 sudo apt install libxkbcommon-dev 安装

    wget http://xkbcommon.org/download/libxkbcommon-0.5.0.tar.xz
    tar xf libxkbcommon-0.5.0.tar.xz
    ./configure —prefix=/usr —libdir=/usr/lib/x86_64-linux-gnu —disable-x11
    make
    sudo make install

    编译libxkbcommon用到yacc,如果没有这个命令,会遇到下面的错误,yacc在 bison软件包中

     sudo apt-get install bison

     YACC     src/xkbcomp/parser.c

    ./build-aux/ylwrap: line 176: yacc: command not found

    make: *** [src/xkbcomp/parser.c] Error 127

  • 相关阅读:
    Microsoft Exchange Mail Flow Rule
    Microsoft Exchange Inactive mailbox
    Microsoft Exchange In-Place Hold and Litigation Hold
    Microsoft Exchange eDiscovery
    Microsoft Exchange Retention Policy
    JavaScript Array 操作
    CSS选择器优先级
    CSS实现垂直居中
    watch和computed和methods区别是什么?
    什么是async和await? 怎么捕获异常?
  • 原文地址:https://www.cnblogs.com/ITGUANCHAZHE/p/14319796.html
Copyright © 2020-2023  润新知