[Qt-interest] SQL (ODBC) retreiving doubles incorrectly
Julien Cugnière
julien.cugniere at gmail.com
Fri Oct 2 13:58:37 CEST 2009
2009/10/2 Andre Somers <andre at familiesomers.nl>
> use qDebug() << on the variant value returned from the query, I get
> QVariant(QString, "E-3") as the result. Retreiving the type of the field
> using QSqlRecord::field() and QSqlField::type() returns QVariant::double
> though.
You can try using query.setNumericalPrecisionPolicy(QSql::LowPrecisionDouble).
If you don't, Qt often returns number as strings in order to preserve
the precision of the database, which can be greater than that of a
double. AFAIK, the exact format of the string is database-dependant,
and there's no guarantee it can be parsed by QString::toDouble.
--
Julien Cugnière
More information about the Qt-interest-old
mailing list