Results 1 to 4 of 4

Thread: Character encoding in text edit and llne edit

  1. #1
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Character encoding in text edit and llne edit

    Hi!

    I programming in qt for half year, but still now I made just english-language software. Today I would like to make something with hungarian characters, so I should use utf8 or iso 8859-2.

    I found this:
    Qt Code:
    1. QString QObject::trUtf8 ( const char * sourceText, const char * comment = 0, int n = -1 )
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. QString::fromUtf8(" ... ")
    To copy to clipboard, switch view to plain text mode 
    - these are good for settings, but how can I get the text of a text edit or a line edit in utf8 format?

    Thank you,
    greenvirag

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Character encoding in text edit and llne edit

    Why dont u use Qt Translations ? Your work wud be much easier.
    Have a look at Internationalization with Qt in Qt Assistant

  3. #3
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,464
    Thanked 272 Times in 267 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Character encoding in text edit and llne edit

    Sorry greenvirag but what is a problem ? QT internaly is working in Unicode. All is described in documentation

  4. #4
    Join Date
    Sep 2008
    Posts
    17
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Character encoding in text edit and llne edit

    Sorry, I asked wrong question.

    I don't need Qt Translation, because the language of the software will be english. But maybe, some user will upload some string using special characters. I get this string:

    Qt Code:
    1. QString description = ui.textEdit->toPlainText();
    2. QString sname = ui.nameLineEdit->text();
    To copy to clipboard, switch view to plain text mode 

    and ok, it can really show these characters. But I need to convert these variables to char*, keeping the special characters.

    My problem, that I didn't see at the first time, is that after the QString --> char* conversation the special characters will be lost.

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.