Results 1 to 3 of 3

Thread: QFile error string is returned in wrong language

  1. #1
    Join Date
    Oct 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default QFile error string is returned in wrong language

    Hello,

    I have an issue with the language used in a string returned from QFile errorString().
    The error is returned in the language defined from system (Windows), but I need to display this message in my application always in english.
    Setting default QLocale doesn't seem to have any effect:

    Qt Code:
    1. // Set language to a different language as defined in QLocale::system()
    2. QLocale::setDefault(QLocale("en_US"));
    3. QFile file("");
    4. file.open(QFile::ReadOnly);
    5. // Error string still in system language
    6. const QString errorString = file.errorString();
    To copy to clipboard, switch view to plain text mode 

    Is there a way to change language used from QFile errorString() or a way to use an existing parser to parse QFile::FileError to a specified language?

  2. #2
    Join Date
    Jan 2006
    Location
    Bremen, Germany
    Posts
    554
    Thanked 86 Times in 81 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QFile error string is returned in wrong language

    You can use http://doc.qt.io/qt-5/qfiledevice.html#error . errorString() is getting it's string from Windows and therefore the Windows locale is used

  3. #3
    Join Date
    Oct 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QFile error string is returned in wrong language

    Yes I know how to get the error code from QFile but I found no parser to parse this error code into a readable string. I don't want to write a parser, when a parser seems to exist somewhere.

    Is there a way to use the parser who is used internaly from QFile class with a specified language?

Similar Threads

  1. Buid error: collect2.exe: error: ld returned 1 exit status
    By Demonlaplce in forum Installation and Deployment
    Replies: 0
    Last Post: 21st April 2016, 10:18
  2. Replies: 2
    Last Post: 13th April 2015, 08:24
  3. Replies: 2
    Last Post: 6th May 2013, 09:06
  4. Replies: 3
    Last Post: 23rd January 2011, 13:15
  5. Replies: 8
    Last Post: 27th March 2007, 11:35

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.