Localization BUG..1.000,00 VS 1,000.00



  • Just did a conversion from V473 to V580.

    Prior to the conversion people in non-English countries IE countries that use a period "." as a thousands separator VS the English comma "," format. used to be able to run an existing program without problems.

    The different format...1,000.00 vs 1.000,00 was just handled by Qt code without issues.

    Now, I'm getting reports form users in non-English countries (so far France, Belgium and Brazil) that the program is throwing errors.. a "nan" in displayed when the formatting cannot be done..instead of displaying a formatted number.

    What changed?

    This used to work.

    How do I fix? Is there a compile flag? Or is this a BUG?



  • Which version of Qt you are using?
    Which os you are working on?
    Which compiler you are using?
    Could you show us some codes?



  • The conversion is done by QLocale and I did not have any problems so far in my programs. Do you have code that uses localised strings in local-unaware methods? for example:

    QString testNum = QLocale(QLocale::French,QLocale::France).toString(1000.0,'f',2);
    double badNum=testNum.toDouble(); // bad!
    double goodNum=QLocale(QLocale::French,QLocale::France).toDouble(testNum); //good
    


  • @tham

    Qt Creator 4.2.1
    Based on Qt 5.8.0 (Clang 7.0 (Apple), 64 bit)
    Built on Jan 20 2017 01:21:01
    From revision 7071b61e02
    Enterprise Features: Enabled
    Licensee: Me

    Copyright 2008-2016 The Qt Company Ltd. All rights reserved.
    The dev system is a MacBook Pro. OS is Sierra 10.12.2

    Can I show you code? The code is NOT the issue. Let me reiterate. The code was working with a PREVIOUS version of Qt. It worked as expected in ALL locales. One compile. One product release. It worked in ALL countries.

    Now it is "broken" for all users that do not use the English/US locale setting.

    The problem occurs when writing formatted text to a field on the UI..something like this..

    ui->lebMarkVelocity->setText( QString::number( ur->arrow->v,'f',2 ) );
    

    ..which causes a display of "nan", instead of the formatted value that you would normally expect. In the above code line, "v" is a double. and "lebMarkVelocity" is a QLineEdit.


  • Lifetime Qt Champion

    Hi,

    Which version of Qt are you using ?

    Are you sure it's not a change of macOS version that triggered that ?



  • @SGaist

    Qt 5.8.0

    All the "nan" occurrences are happening on customer systems. Not sure what OSes they are using.

    My previous IDE was QT 4.7.3 and MacOS 10.8.5

    Customers that used the product built on 4.7.3/10.8.5 had no issues.

    The same customers who upgraded to the product built on 5.8.0/10.12.2 (presumably on the same computer) have issues.



  • @PSI_lbc said in Localization BUG..1.000,00 VS 1,000.00:

    ui->lebMarkVelocity->setText( QString::number( ur->arrow->v,'f',2 ) );

    could you try and replace it with: ui->lebMarkVelocity->setText( ui->lebMarkVelocity->locale().toString(ur->arrow->v,'f',2)); even though I doubt the problem is here. QString::number does not care about locale, it's when you do the opposite (from string to double) that it should hit

    @PSI_lbc said in Localization BUG..1.000,00 VS 1,000.00:

    The code is NOT the issue. Let me reiterate. The code was working with a PREVIOUS version of Qt. It worked as expected in ALL locales.

    There have been some serious changes from Qt4 to Qt5 so it might just be that code that Qt4 swallowed anyway now causes an issue


Log in to reply
 

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