QCustomPlot Discussion and Comments

How to fix Number format for Axis Ticks ?Return to overview

Hi all, I have a problem with setting number precision for QCPAxis.
I want to display the ticks up to 2 decimal points only. So when I set the NumberPrecision to 2, I got the following result:

0.256 --> 0.26 [Expected = 0.26] OK
10.256 --> 10 [Expected = 10.26] NOT OK

How to display 10.256 as 10.26 ?

As everywhere in Qt, here's the documentation for the argument formats:
https://doc.qt.io/qt-5/qstring.html#argument-formats
Quoting from there:
A precision is also specified with the argument format. For the 'e', 'E', and 'f' formats, the precision represents the number of digits after the decimal point. For the 'g' and 'G' formats, the precision represents the maximum number of significant digits (trailing zeroes are omitted).

So what you're seeing is correct. You have configured two significant digits. If you want fixed point representation, you should set the number format to 'f'.

Thanks Isso.