Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-47192

[REG 5.4.2->5.5,0] Conversion from QVariant to QString is broken for double and float values

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P1: Critical
    • None
    • 5.5.0
    • None
    • Windows 8.1 x64; MSVC 2013 Community; Qt x32;

    Description

      Here is an example:

      #include <QCoreApplication>
      #include <QDebug>
      
      int main(int argc, char *argv[])
      {
      	QCoreApplication a(argc, argv);
      	QVariant v = 800.79f;
      	QVariant v2 = 800.79;
      
      	qDebug() << v << v.type() << v.toString();
      	qDebug() << v2 << v2.type() << v2.toString();
      
      	return a.exec();
      }
      

      Output with Qt 5.4.2:

      QVariant(float, 800.79) "800.79"
      QVariant(double, 800.79) "800.79"
      

      Output with Qt 5.5.0:

      QVariant(float, 800.79) "800.789978"
      QVariant(double, 800.79) "800.78999999999996"
      

      I write finance app and get data from database using QSqlQuery+QSqlRecord classes which convert DB's numeric fields into QMetaType::Double and this is pretty critical for me.

      Attachments

        Issue Links

          Activity

            People

              thiago Thiago Macieira
              aas AAS
              Votes:
              1 Vote for this issue
              Watchers:
              15 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: