Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.12.12
-
None
Description
All in the title. Here is my use case :
I want to display localized storage size, but with the following rule for the number :
- Show 2 decimals
- Do not show trailing zeros.
For example, if the size is 3.58 Mb, it should be displayed as 3.58 Mb.
If the size 3.50 Mb, it should be displayed as 3.5 Mb
If the size is 3.00 Mb, it should be displayed as 3 Mb
Here is my attempt to do it with QT :
int precision = 2; QLocale locale = QLocale::system(); locale.setNumberOptions(QLocale::RejectTrailingZeroesAfterDot); return QLocale::system().formattedDataSize(bytes, precision, QLocale::DataSizeTraditionalFormat);
What I get from this code :
- 3.50 Mb in the first case
- 3.00 Mb in the second case
Attachments
Issue Links
- is covered by
-
QTBUG-82831 Do byte-amount formatting less wrongly
- Reported