Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Displaying Japanese characters in Qt

Displaying Japanese characters in Qt

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 2 Posters 3.4k Views 1 Watching
  • 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 Offline
    J Offline
    jisjohn
    wrote on last edited by
    #1

    Dear all,

    I am trying to display Japanse characters on my display using QPainter. I followed the below approaches

    1, Set the QFont to "japanse", set font size to 24 and font set as bold, (pasted the code snippet below) I expected the output to be displayed in white colour with a blue outline and with the above mentioned font parameters, but the text was displayed in blue colour with a lesser font size and was not bold.

    2, I tried as per mentioned in the post http://qt-project.org/forums/viewthread/32704 but I am getting junk characters in the display.

    Regards,

    Jis

    @
    QPainter * painter1;
    QFont m_textFont;
    QPen m_bluepen;
    QBrush m_whiteBrush;
    this->m_textFont.setPointSize(24); //increased text font size from 21 to 23 for error messages and date and time
    this->m_textFont.setBold(true);
    this->m_textFont.setFamily("japanese");
    whitepath.addText(20,400,this->m_textFont,QString::fromUtf8("警察は、バックステー"));
    whitepath.addText(20,400,this->m_textFont,obj_verbalWarning.message_id);
    painter1->setPen(this->m_bluepen);
    painter1->setBrush(this->m_whiteBrush);
    painter1->drawPath(whitepath);
    @

    [edit: Added missing coding tags @ SGaist]

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi, and welcome to the Qt Dev Net!

      [quote]
      @
      QString::fromUtf8("警察は、バックステー");
      @
      [/quote]This requires your .cpp file to be encoded in UTF-8. Have you checked that you have saved it in UTF-8, and not SHIFT-JIS or something else?

      Also, what OS and compiler are you using?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jisjohn
        wrote on last edited by
        #3

        Hi JKSH,

        We are using linux (Kernel version 2.6.35) and gcc compiler.
        The file is saved in UTF-8-BOM encoding.

        Regards,

        Jis

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jisjohn
          wrote on last edited by
          #4

          Hi JKSH,

          We followed the approach 2 as mentioned above and used the font "osaka.unicode" instead of "katakana", now we are able to display the japanese characters on our screen.

          Regards,
          Jis

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved