Solution to the QT program cannot input Chinese in Linux (connect with below)

Source: Internet
Author: User
Tags chmod gtk locale wubi

Before installing the QT Integrated Development Kit, you need to install both the build-essential and Libncurses5-dev development tools and libraries, the Libncurses5-dev library is a library of graphics functions that are widely used under Linux/unix. Build-essential includes some of the necessary tools for Linux development. In Ubuntu we use QT to develop and use these two tool libraries. The installation command is: sudo apt-get install build-essential Libncurses5-dev.

After this library installation is complete, you can install the QT SDK, the following installation steps:

1. Download the QT SDK installation package.

2. Execute the command on the path where the installation package is located:

sudo chmod u+x qt-sdk-linux-x86-opensource-2010.04

sudo./qt-sdk-linux-x86-opensource-2010.04

3, install after the completion of a self-brought example, to see if the normal compile and run, if able to run the proof has been installed successfully.

This article refers to a lot of other authors of the content, but also forget the citation of the source, can only thank. The following turn to the chase. This article goes from the blog, thank you very much

For qt5.5, to download LIBQT Library source code itself compiled, reference resolution QT5 creator cannot switch input method (FCITX), Ubuntu can not use the Sogou input method input Chinese character problem

Linux has two input methods, respectively, IBUs and FCITX, if you like Sogou input method, you need to install FCITX.

First of all, the first input method IBUs.

First, IBUs

The installation steps are as follows:

First: Install the IBUs frame,

sudo apt-get install ibus ibus-clutter ibus-gtk ibus-gtk3 ibus-qt4

Start the IBUs frame and enter it in the terminal:

Im-switch-s IBUs

After installing the IBUs framework, log off the system to ensure that changes take effect immediately.

Note that there may be an error, as follows: No configuration file "IBUs" exists. The workaround is to modify the Im-switch profile, as follows:

$ cd/etc/x11/xinit/xinput.d/$ sudo cp default IBUs $ sudo vim ibus

To edit a configuration item in vim:

Xim=ibus Xim_program=/usr/bin/ibus-daemon xim_args= "-xim"

After creating the configuration file and then restarting Im-switch, you can find that this time can be selected to IBUs, and the parentheses are our profile name, through the configuration file will be set point to the IBUs daemon Ibus-daemon, So every time X is started, it can automatically associate the input method, as follows:

Step three: Install the Pinyin engine

There are several common options:

IBUs Pinyin: sudo apt-get install Ibus-pinyin

IBUs Wubi: sudo apt-get install Ibus-table-wubi

Google Pinyin Input method: sudo apt-get install Ibus-googlepinyin

Sun Pinyin Input Method: sudo apt-get install Ibus-sunpinyin

Fourth step: Setting the IBUs frame

Ibus-setup

Set IBUs

Fifth Step: Environment variable setting

Typically, the IBUs icon (a small keyboard) appears in the taskbar in the upper-right corner of the desktop. Sometimes this icon disappears on its own, using the following command to retrieve the vanishing IBUs icon:

Ibus-daemon-drx

To enable input methods, you also need to configure environment variables, as follows (IBUs supports XIM protocol and GTK IM modules and Qt im modules):

Export Gtk_im_module=ibus
Export Qt_im_module=ibus
Export [Email Protected]=ibus

To enable Input method support for QT, proceed as follows:

/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so

Copy the file to

QT installation directory/tools/qtcreator/bin/plugins/platforminputcontexts (function is to enable the Qtcreator development environment to support input method)

And

QT installation directory/5.3/gcc_64/plugins/platforminputcontexts (personal guess is to make the compiler compiled by the QT program also support Input method)

In

If the program developed by QT does not support input method, then you can create the Platforminputcontexts directory in the directory where the program resides, and then copy the libibusplatforminputcontextplugin.so into it. Published with the executable program to publish, if still not, restart the computer, re-run the executable program.

Boot Start IBUs

System >> Preferences >> Startup applications
Click the Button:add
Name:ibus Daemon
Command:/usr/bin/ibus-daemon-d
Comment:start IBUs Daemon When gnome start

System >> Preferences >> Startup applications
Click the Button:add
Name:ibus Daemon-open
Command:/usr/bin/ibus-daemon-drx

Comment:start IBUs Daemon When gnome starting

Common commands:

Im-switch-s IBUs #启动ibus框架

Ibus-setup #设置ibus框架

Ibus-daemon-drx #通常情况下, the IBUs icon (a small keyboard) appears in the taskbar in the upper-right corner of the desktop. Sometimes this icon disappears on its own, using the following command to retrieve the vanishing IBUs icon

Im-switch #设置系统输入法

$ sudo killall ibus-daemon #重启ibus

$ sudo ibus-daemon-d–xim

Second, Fcitx Input method:

1, install FCITX for QT5 Dynamic library, so as to get the dependent library required

Execute the following command: sudo apt-get install FCITX-LIBS-QT5

Install Fcitx Input Method frontend: sudo apt-get install FCITX-FRONTEND-QT5

2. Configure FCITX Environment variables:

Export [Email PROTECTED]=FCITX

Export XIM=FCITX

Export XIM_PROGRAM=FCITX

Export GTK_IM_MODULE=FCITX

Export QT_IM_MODULE=FCITX

3.1 Let Qtcreator development environment support Sogou Input Method:

Enter the following path to the QT installation directory: {path} is the installation directory for QT Cd{path} (Use the command dpkg-l package name to see the file installation path)

/qt5.3.1/tools/qtcreator/bin/plugins/platforminputcontexts

Copy Fcitx Input Method support file: Execute the following command to copy the support file to the above directory sudo cp/usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/ Libfcitxplatforminputcontextplugin.so. (for 32-bit systems, the corresponding directory is/usr/lib/i386-linux-gnu/qt5/plugins/platforminputcontexts/

)

Add the executable command for the file just now: chmod+x libfcitxplatforminputcontextplugin.so restart QT can use Sogou Input Method!! If still not, restart the computer, and then re-open qtcreator on it. But the original CTRL + space is the code hint shortcut, which is now used to toggle the IME. This is also good to solve:
Qt Creator---> Tools---> Options---> Environment---> Keyboards. And then find the complete this modification

3.2 Let Qt5 developed the program also support Sogou Input method:

When you publish the program to the directory where the program is located, you need to create the Platforminputcontexts directory in the project directory and then put the/usr/lib/x86_64-linux-gnu/qt5/plugins/ platforminputcontexts/ libfcitxplatforminputcontextplugin.so Copy to the Platforminputcontexts directory, with the program release, you can let QT developed programs in other machines can also support FCITX input method, if still not, Restart your computer and rerun the executable program.

   

   

Common commands:

Im-switch-s FCITX Toggle Current Input method to FCITX

Im-switch-s fcitx-z Default #将fcitx设为默认输入法

Summarize

QT installation directory/5.3/gcc_64/plugins This directory is the QT creator compiled by the program runtime calls the plugin directory, so this input method plug-in to this. As if you were creating a new one under the compiled program.
It is also possible to put libfcitxplatforminputcontextplugin.so in the plugins/platforminputcontexts/directory.
QT installation directory/tools/qtcreator/bin/plugins/This directory is the QT creator itself calls the plugin directory, so want to enter in the QT creator Chinese here also to put one.

Test results:

Test environment: Linux gdlctech-system-product-name 3.13.0-24-generic #46-ubuntu SMP Thu Apr 19:11:08 UTC x86_64 x86_64 x86_6 4 Gnu/linux

Test program (The following programs can be run at the same time as normal use of input method, no conflict):

qt4.8.5 (installed with your own system)

Qtcreator and the programs it developed)

qt5.3.1 (32-bit Qtcreator executable and program developed with it)

Qt4.7.4 (Jinshan wps)

QQ program (should be a version of Qt4)

Note: When the IBUs and Fcitx input method runs simultaneously, the switch input method will have the conflict!! So, do not put two input methods at the same time run!!

http://blog.csdn.net/u013281495/article/details/50560817

(The first time configuration ArchLinux error is much AH)

After the installation of the system found that although the installation of IBUs, but QT program can not input, the heart puzzled, also very depressed. -I installed KDE.

Search data on the Internet, the method is a variety of, but, for the SCIM or FCITX problems, IBUs have no, try, the effect is not good, have failed. Found another post, someone replied: "Is the locale is not set good", suddenly remembered, the original listen to the wiki suggestions, in order to prevent garbled not set locale, try locale bar.  Open/etc/locale.gen, the ZH_CN before the # is all deleted, enter the sudo locale-gen, prompted to successfully set. Try typing Chinese again and still fail.here the system default locale is still en_US, and the locale command will knowThink about it and turn on system settings-language, manually set the Chinese to system default.

Attempt to enter Chinese, still failed.also need to open the login interface to setFinally find ArchLinux wiki, in the locale settings have the following text: In the KDE or GNOME desktop environment, by the respective System Manager settings KDM or GDM. (The login manager's configuration file determines the system language) because it was installed without KDM Manager, so the installation is GDM, started is GDM, is this the reason? But KDM how to install it? Looking for wikis, KDM is included in the installation package for Kdebase-workspace, the KDE desktop. Open/usr/bin, see KDM impressively in the inside lie! It turns out I've already installed it. Then modify the/etc/rc.conf, the last line of GDM, changed to KDM, restart the system. Finally, the experiment was successful!only partially supported at this timeAdditional words: In fact, after the above settings are completed, and did not succeed in all the QT program to enter Chinese, Add the following settings: First set the Locale.gen error, initially just put Chinese into the list of supported languages, but did not become the default language, the second does not install the QT version of IBUs, need to continue to do the following actions: Run terminal, input pacman-s ibus-qt# Install QT support to open ~/.BASHRC, add the following text: Export xmodifiers= "@im =ibus" Export Gtk_im_module=ibusexport qt_im_module=ximexport IBUs &export Lc_ctype=zh_cn.utf8 Save # New ibus.sh, add the above statement and ibus-daemon-d to it, and finally set the script for the system self-booting, you do not need to start the terminal first. Then, open the System settings systemsettings, select "Login Settings", in the drop-down menu set the login interface language to "ZH_CN UTF-8", restart the system. After doing this, enter Qtconfig to open QT settings, switch to the "interface" option, and change the default input method to IBUs. After all this open QT program, all support IBUs.

Solution to the QT program cannot input Chinese in Linux (connect with below)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.