Results 1 to 5 of 5

Thread: Confusions about displaying Chinese in qt applications

  1. #1
    Join Date
    Sep 2011
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Cool Confusions about displaying Chinese in qt applications

    I am really confused about displaying Chinese!
    First,my windows' language is Chinese.To display Chinese in my app,I searched the Internet and found that I could add the following code to my app and used tr() where I wanted to display Chinese.
    Qt Code:
    1. QTextCodec::setCodecForTr(QTextCodec::codecForName("GBK"));
    To copy to clipboard, switch view to plain text mode 
    To my release,it really worked very well.However,when I opened my app in my friend's computer,it did't work correctly.My friend's os is also win xp in Chinese!
    Then I added the following codes to my app rather than the former one.
    Qt Code:
    1. QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
    2. QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
    To copy to clipboard, switch view to plain text mode 
    It works perfectly whether on my computer or my friend's.
    What happens?
    And if I run this app on an English os,can it work correctly?If not,what should I do?Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Confusions about displaying Chinese in qt applications

    How do you place chinese characters in your code? What do you put inside tr() calls?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2011
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Confusions about displaying Chinese in qt applications

    Just like this tr("ä¸*文示例") . And can you be sure thar if I write :
    Qt Code:
    1. QTextCodec::setCodecForCStrings(QTextCodec::codecForLocale());
    2. QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
    To copy to clipboard, switch view to plain text mode 
    it will work everywhere?Or what do you think is the right way to display Chinese?Thank you !

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Confusions about displaying Chinese in qt applications

    You should place English calls inside tr() and then provide Chinese translation files for QTranslator.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    furskytl (19th October 2011)

  6. #5
    Join Date
    Sep 2011
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Confusions about displaying Chinese in qt applications

    Ok!Thanks !I will try soon!

Similar Threads

  1. QT4.6.3 to QT4.7.3 Font problem (Chinese)
    By batileon in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2011, 17:22
  2. QTextEdit and Chinese characters on a Mac
    By jupi32000 in forum Qt Programming
    Replies: 0
    Last Post: 17th February 2010, 02:02
  3. I have a problem ,how to get chinese unicode ?
    By tsuibin in forum Qt Programming
    Replies: 5
    Last Post: 8th April 2009, 10:26
  4. how can I input and display Chinese using QT4?
    By Justin_W in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 12th August 2008, 18:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.