PDA

View Full Version : QString::number(v, 'g', 3), how to change limits of 'g' for log. values



HappyCoder
24th July 2015, 09:37
Hi,

have values (v) from 2000 to 1E-10 and with that i got on a logarithmic axis

1000, 100, 10, 1, 0.1, 0.01, 0.001, 0.0001, 1E-05 ... and so on

How to modifiy it that values below 0.01 are in e-format

1000, 100, 10, 1, 0.1, 0.01, 1e-3, 1e-4, 1e-5 ...

Thx

STM
24th July 2015, 10:06
Hi,

change the 'g' to 'e' or 'E' as you can see here (http://doc.qt.io/qt-5/qstring.html#argument-formats).

HappyCoder
24th July 2015, 10:25
Hi,

change the 'g' to 'e' or 'E' as you can see here (http://doc.qt.io/qt-5/qstring.html#argument-formats).

You didn't understand it, that changes ALL values into e-format, not only some.
Nevermind, i found it by myself.

d_stranz
24th July 2015, 17:27
Nevermind, i found it by myself.

Well, good. Keep it a secret. After all, the purpose of this forum isn't really to share information, it's to get help for yourself only, right?

HappyCoder
27th July 2015, 06:46
Well, good. Keep it a secret. After all, the purpose of this forum isn't really to share information, it's to get help for yourself only, right?

No panic, i had already written it here. Can i check it first if it realy works? Right?


The only solution i found was to check the value in a func an return it formated.



if( v >= 1E-1 )
return QString::number(v, 'G', 3);
else
return QString::number(v, 'e', 0);