Convert more accurately decimal numbers to text.

This commit is contained in:
sledgehammer999
2014-01-21 01:47:30 +02:00
parent 4d3672f894
commit 441d1d08ba
10 changed files with 39 additions and 48 deletions

View File

@@ -65,9 +65,7 @@ class PreviewListDelegate: public QItemDelegate {
QStyleOptionProgressBarV2 newopt;
qreal progress = index.data().toDouble()*100.;
newopt.rect = opt.rect;
/* HACK because QString rounds up. Eg QString::number(0.999*100.0, 'f' ,1) == 99.9
** but QString::number(0.9999*100.0, 'f' ,1) == 100.0 */
newopt.text = QString::number((int)(progress*10)/10.0, 'f', 1)+"%";
newopt.text = misc::accurateDoubleToString(progress, 1);
newopt.progress = (int)progress;
newopt.maximum = 100;
newopt.minimum = 0;