Solution to the problem of unable to input Chinese when installing Qt5.12.12 under Ubuntu

Solution to the problem of unable to input Chinese when installing Qt5.12.12 under Ubuntu

1. Environment:

(1) VMware Workstation 15 Pro
(2) Ubuntu 20.04
(3) Qt 5.12.12 64bits
(4) Qt Creator 5.0.2
(5) fcitx, google Pinyin and Sogou Pinyin have been installed.

2. Problem description:

After installing Qt 5.12.12, I opened Qt Creator and found that I could not input Chinese. Even if I clicked the keyboard in the upper left corner of Ubuntu, I could not switch to Chinese input. Ubuntu had already installed Fcitx. But it is possible to input Chinese in other environments.

3. Cause analysis:

Because the input method framework under Ubuntu has two ibus and fcitx, the input method under ibus is not very easy to use, so I installed fcitx, and installed the Google input method and Sogou input method. At this point, you can input Chinese in the Ubuntu terminal. However, the QT platform does not support Chinese input. The main reason is that QT cannot input Chinese by default and does not have a built-in Chinese input method. It can only realize Chinese input through the operating system or other third-party input method plug-ins.
Insert image description here

Fourth, solution:

Because Fcitx has been installed before, (operate according to the official guidance document of Sogou input method),
Insert image description here

So we directly install fcitx-libs-qt or fcitx-libs-qt5. After the installation is completed, search for the libfcitxplatforminputcontextplugin.so file on the computer. Taking my virtual machine as an example, the location of the file is: / usr/lib/x86_64-linux-gun/qt5/plugins/platforminputcontexts, and the other is the location of the installed Sogou input method, /opt/sogoupinyin/files/lib/qt5.bak/plugins/platforminputcontexts/;
Here I use the usr/lib directory in the system directory, then copy the file to the /opt/Qt5.12.12/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts/ directory, and then restart QtCreator. That’s it;
Insert image description here

As shown in the picture above, in these two directories, the purple box is the file I copied. Previously, there was only libibusplatform... file in this directory, so it should be that only the ibus input method framework was supported before. I put libfcitxplatforminputcontextplugin.so here. in these two directories. Make sure that Chinese can be entered in both QT Creator and code.

Guess you like

Origin blog.csdn.net/bxlover007/article/details/132558389