Important: Please read the Qt Code of Conduct -

QVariant::toString - default precision setting changed?

  • Hello!
    I recompiled my application using Qt5.6 and VS2015 (win32) and noticed that QVariant::toString nowadays converts with "full precission", thereby showing the non-perfect representation of many decimal values. Although not wrong by itself it is very confusing for the user. E.g. 59.600000000000001 where the user would expect 59.6. The same source, compiled with VS2008 and Qt5.4 displays the rounded values.
    Of course I can work around that by QString::number(QVariant::toDouble()) but I am slightly troubled aboubt this silent change in behaviour and I wonder if it is due to Qt5.4 -> Qt5.6 or VS2008 -> VS2015 (which I can't test, because i have no VS2008 at hand any more):
    Did anyone else observe similar changes and what do you think about it? Does it qualify as a bug?

  • @stryga42 Hi, and welcome to the Qt forum! The dev who introduced the change in behaviour says that it's not a bug but a feature, see QTBUG-47192.

  • Well, got it, thanks for pointing to the bug report. Would be great if the doc for QVariant::toString could elaborate more about how string conversion is done for non-string types of QVariant. Would save some debugging :-)
    Is there a bug-tracker for the documentation where I coulld add my request?
    Thanks, stryga42

  • @stryga42 You can use the bug tracker for documentation bugs / requests, too: