Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Unable to input Chinese (Chinese characters) ?

    Qt for WebAssembly
    5
    8
    669
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      Jonix King last edited by

      Unable to input Chinese (Chinese characters) ?
      How to solve it?

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        You might want to give more details about your situation.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • lorn.potter
          lorn.potter last edited by

          Qt for WebAssembly currently does not support using local (system) fonts.
          https://bugreports.qt.io/browse/QTBUG-81736

          You can add fonts to a resource file or download the fonts into the platform sandbox and then use
          QFontDatabase::addApplicationFont or
          QFontDatabase::addApplicationFontFromData(b) to load the font.

          You can then pick your font from the font chooser.

          That part would work. Whether it will display correctly and be able to actually input might be a hit and miss right now. I have not been able to test font handling lately.

          Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
          Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

          J 1 Reply Last reply Reply Quote 1
          • J
            Jonix King @lorn.potter last edited by

            @lorn-potter Thank you very much.
            I know how to display Chinese characters normally:

                int fontId = QFontDatabase::addApplicationFont(QStringLiteral(":/fonts/msyh.ttf"));
                QStringList fontFamilies = QFontDatabase::applicationFontFamilies(fontId);
                if ( fontFamilies.size() >0 )
                {
                    QFont font;
                    font.setFamily(fontFamilies[0]);
                    app.setFont(font);
                }
            

            But ...
            Just can't input Chinese characters
            The problem made it impossible for me to start Chinese software. @_@

            J 1 Reply Last reply Reply Quote 0
            • J
              jineter @Jonix King last edited by

              @Jonix-King 解决了吗?不能输入的问题点在哪里?是否可以通过修改qt源代码的方式进行支持?

              J 1 Reply Last reply Reply Quote 0
              • W
                wenqing zhong last edited by wenqing zhong

                what do you mean "can't input Chinese characters"?
                Cannot input chinese words when run in web-browser? I never meet that situation.
                Cannot input chinese words in QT creator linux? May be, but you can find solution in the network. In windows, never heard of such problem.

                1 Reply Last reply Reply Quote 0
                • W
                  wenqing zhong last edited by

                  No, I am wrong! that is really a fatal problem. Line edit in wasm can only input english and number, but not Chinese characters. Now I can only paste the Chinese words to input widget. That is realy a nightmare.

                  1 Reply Last reply Reply Quote 0
                  • J
                    Jonix King @jineter last edited by

                    @jineter 已知唯一解决方案是在WASM中自己做一个输入法。已经有人搞出了虚拟键盘+拼音输入,据说可以满足需求。由于不肯开源只看到了截图。em编译器的说明中没有看到输入法限制方面的说明,无法判断是否是em的原因所致;但感觉Qt自身原因的可能性更大一些。

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post