Results 1 to 3 of 3

Thread: Inserting non English string into PlainTextEdit

  1. #1
    Join Date
    Nov 2009
    Location
    Internet
    Posts
    11
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Inserting non English string into PlainTextEdit

    Hi all,

    I create a plain text edit on a widget in designer. when I set the plainText property in designer to s.th like "تست" there's no problem and it works properly, but when I use code to do that:

    Qt Code:
    1. ui->PlainTextEdit->setPlainText("تست");
    To copy to clipboard, switch view to plain text mode 

    the text appear in the plain text edit is s.th like: ???

    - Default file encoding of my project is UTF-8
    - I changed the locale in designer too but it was not the solution
    - I read Internationalization with Qt. I don't want my app support multi languages. I want it just be in my language.

    should I make the program in English and then translate it?
    any hint?
    Last edited by soulless; 13th February 2010 at 17:51.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Inserting non English string into PlainTextEdit

    You have to use QString::fromUtf8() or better use QObject::trUtf8().

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

    soulless (13th February 2010)

  4. #3
    Join Date
    Nov 2009
    Location
    Internet
    Posts
    11
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Inserting non English string into PlainTextEdit

    Quote Originally Posted by Lykurg View Post
    You have to use QString::fromUtf8() or better use QObject::trUtf8().
    I opened my cpp file with an external editor and realize that it's encoded in ASCII !!!! I saved it in utf-8 and used what you said. Everything is fine now, tnx.

Similar Threads

  1. Switching QtCreator to English?
    By Asperamanca in forum Qt Tools
    Replies: 4
    Last Post: 1st September 2009, 08:05
  2. How to make plainTextEdit autofill to parent window?
    By kid2000 in forum Qt Programming
    Replies: 7
    Last Post: 17th February 2009, 10:59
  3. Replies: 0
    Last Post: 19th August 2007, 06:47
  4. menus with non-english language
    By aegis in forum Qt Programming
    Replies: 5
    Last Post: 31st March 2007, 21:54
  5. inserting string > 127 characters to MS Access
    By jh in forum Qt Programming
    Replies: 0
    Last Post: 12th May 2006, 18:11

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.