Results 1 to 3 of 3

Thread: why .fromLocal8Bit() is needed

  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default why .fromLocal8Bit() is needed

    hi friends,
    i gone through one good examlpe which use QProcess() and in that i have one doubt ...
    i try all the assistant documents but cant find ... what is the difference between this two .. to get readyReadStandardError() from QProcess()
    Qt Code:
    1. 1.
    2. QString path = process.readAllStandardError();
    3. path = outputtextedit->setText(path);
    4.  
    5. 2.
    6. QByteArray newData = process.readAllStandardError();
    7. QString text = outputTextEdit->toPlainText()
    8. + QString::fromLocal8Bit(newData);
    9. outputTextEdit->setPlainText(text);
    To copy to clipboard, switch view to plain text mode 
    why we need to convert QString as like 2 nd one .... what will happen if i use 1 st condition ..?

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

    Default Re: why .fromLocal8Bit() is needed

    The first one will use latin1() encoding conversion, the second one will use conversion dependent on your system.
    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 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: why .fromLocal8Bit() is needed

    Quote Originally Posted by wysota View Post
    The first one will use latin1() encoding conversion, the second one will use conversion dependent on your system.
    thanks for reply .....
    which one is best to follow if my process outputted as
    "joystick failed due to ... failure and network closed "

    we have to use QByteArray() to get output and put that one in QString should be used ..?
    if not using QByteArray() will create a problem?

Similar Threads

  1. help needed in QMouseEvent
    By aj2903 in forum Qt Programming
    Replies: 21
    Last Post: 14th February 2009, 11:15
  2. Qt4Libraries needed for using images
    By divya balachandran in forum Qt Programming
    Replies: 2
    Last Post: 23rd January 2009, 21:52
  3. realtime_plot example problem--help needed.
    By swamyonline in forum Qwt
    Replies: 8
    Last Post: 17th July 2008, 19:12
  4. Map Projection Basics in Qt--help needed
    By swamyonline in forum Qt Programming
    Replies: 1
    Last Post: 9th July 2008, 21:32
  5. Forward declarations needed for some?
    By doktorn in forum Newbie
    Replies: 6
    Last Post: 28th November 2007, 08:56

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
  •  
Qt is a trademark of The Qt Company.