Results 1 to 7 of 7

Thread: Cannot get QT Gui Application to display chinese

  1. #1
    Join Date
    Sep 2010
    Posts
    6
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Cannot get QT Gui Application to display chinese

    Hello, I am new to the QT SDK 4.6.1 and currently learning qt through C++-GUI-Programming-with-Qt-4-1st-ed

    I am trying to display some chinese words in a simple qt windows and it shows up all rubbish.

    here is the code

    Qt Code:
    1. #include <QApplication>
    2. #include <QLabel>
    3.  
    4. int main( int argc, char* argv[])
    5. {
    6. QApplication App(argc,argv);
    7. QLabel *label = new QLabel("XXXX"); //where XXXX is chinese character
    8. label -> show();
    9. return app.exec()
    10. }
    To copy to clipboard, switch view to plain text mode 

    The code ran well and showed a little windows, the only problem is that the chinese character are messed up.

    It would be nice if someone can show me how to solve these problems or I might as well just go back to MFC.

    ps.
    I've been search through internet for solutions; however, nothing mentionable has been found. I've read the internationlization with QT and tried
    Qt Code:
    1. QString text = "XXXX";
    2. QLabel *label = new QLabel(text);
    To copy to clipboard, switch view to plain text mode 

    and it did not work. I donno the tr() function as there is no real example that solved the multi-langue display problem
    Last edited by Weichen; 18th September 2010 at 17:39.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Cannot get QT Gui Application to display chinese


  3. The following user says thank you to tbscope for this useful post:

    Weichen (19th September 2010)

  4. #3
    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: Cannot get QT Gui Application to display chinese

    In what encoding is the chinese character you are trying to put into this QString?
    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:

    Weichen (19th September 2010)

  6. #4
    Join Date
    Sep 2010
    Posts
    6
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot get QT Gui Application to display chinese

    Quote Originally Posted by wysota View Post
    In what encoding is the chinese character you are trying to put into this QString?
    I want to encode traditional chinese. It would be nice if I am able to encode simpliied chinese too

  7. #5
    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: Cannot get QT Gui Application to display chinese

    No, you didn't understand me. I'm asking what is the text encoding of the characters you input in the file. I'm not asking whether it is simplified or traditional, I'm asking about the glyph encoding. If you don't know what that is, please ask your favourite web search engine. I can give you a hint, it could be BIG-5, but it could also be UTF-8 or something else.

    You can start reading here: http://en.wikipedia.org/wiki/Chinese_character_encoding
    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.


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

    Weichen (19th September 2010)

  9. #6
    Join Date
    Aug 2010
    Posts
    22
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot get QT Gui Application to display chinese

    wysota was correct.
    For specific details on Qt and Chinese characters, refer http://hi.baidu.com/cyclone/blog/ite...d6538dbf1.html

  10. The following user says thank you to jezz for this useful post:

    Weichen (19th September 2010)

  11. #7
    Join Date
    Sep 2010
    Posts
    6
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Cannot get QT Gui Application to display chinese

    Quote Originally Posted by jezz View Post
    wysota was correct.
    For specific details on Qt and Chinese characters, refer http://hi.baidu.com/cyclone/blog/ite...d6538dbf1.html
    Thank you. that blog was a great help

Similar Threads

  1. Problem with chinese and japanese characters display
    By manojmka in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 26th February 2010, 05:09
  2. Application doesn't display images
    By satoshi in forum Qt Programming
    Replies: 3
    Last Post: 2nd January 2010, 11:33
  3. How to display chinese chars with QtEmbedded-4.5.3
    By amaolei in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 15th December 2009, 06:47
  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, 17:46
  5. Loading chinese font for the application
    By kommu in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2008, 14:12

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.