Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Can't input Chinese in QPlainTextEdit



  • I have a small text editor program using QTextEdit. When I
    changed to using QPlainTextEdit, it interpreted the keystrokes (in
    Chinese input mode) as normal latin1 characters!!! Can anyone help
    solving this problem. I am using Fedora29 and Qt5.


  • Lifetime Qt Champion

    Hi,

    What happens if you load a text containing chines characters in that widget ?



  • In almost aspects (display, find,...) QTextEdit and QPlainTextEdit
    behave the same in my simple editor. Except Chinese can't be keyed
    in if switched to using QPlainTextEdit.


  • Lifetime Qt Champion

    @wij2 which Qt version is that exactly?



  • [wij2@localhost]$ qmake-qt5 --version
    QMake version 3.1
    Using Qt version 5.11.3 in /usr/lib64


  • Lifetime Qt Champion

    Did you check the bug report system ?



  • I checked the indicated web page just now, nothing relevant (keyword=QPlainTextEdit)

    The following are messages dumped on the terminal, hope it could provide more hints: (Except the issue that Chinese can't be input in QPlainTextEdit, the other one is Segmentation fault after su)

    [wij2@localhost]$ env | grep SESSION
    XDG_SESSION_ID=2
    DESKTOP_SESSION=gnome
    XDG_SESSION_TYPE=wayland
    XDG_SESSION_DESKTOP=gnome
    GDMSESSION=gnome
    DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
    SESSION_MANAGER=local/unix:@/tmp/.ICE-unix/1596,unix/unix:/tmp/.ICE-unix/1596
    [wij2@localhost]$ ./simple_qed
    Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
    ^C
    bash: history: write error: Success
    [wij2@localhost]$ su
    Password:
    [root@localhost]# ./simple_qed
    Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
    Qt: Session management error: None of the authentication protocols specified are supported
    Segmentation fault
    [root@localhost]#



  • Same problem:

    At first, I can't input Chinese in anywhere cause my ubuntu don't have this support:

    libfcitxplatforminputcontextplugin.so
    

    You can check this by:

    dpkg -L fcitx-frontend-qt5 | grep .so
    

    to find where's the .so file. If not, just install it:

    sudo apt-get install fcitx-frontend-qt5
    

    And next, you should copy this .so file to your Qt install package path, like this:

    $ cd Qt5.9.0/Tools/QtCreator/lib/Qt/plugins/platforminputcontexts/
    $ cp /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so .
    

    Don't forget:chmod +x libfcitxplatforminputcontextplugin.so
    Finally, restart Qt Creator and you can input Chinese in your code now.

    However, sadly, I can't input Chinese in QPlainTextEdit. Need Help!


Log in to reply