Localization strings with Unicode characters



  • Hi there.

    I'm using Qt 4.8 and I need to localize some string in the qml file, which contains Unicode characters. Example:

    Label {
        text: qsTr("°C")
    }
    

    But after the localization, my app continue to display °C instead of درجة مئوية. What am I doing wrong?



  • Solution:

    • inside main.cpp after creating the application object add the following line:
    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
    
    • inside .pro file add the following line:
    CODECFORTR = UTF-8
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.