Maybe qBound<qreal>(0.0, (qreal)value / total, 1.0);