Showing numbers in decimal not scientific notation
Unsolved
General and Desktop
-
Hi,
for your specific situation, I would suggest something like:
QString truncValue(double value, int prec) { QString sReturn = QString::number(value,'f',prec); if(sReturn.endsWith("0")){ while(sReturn.endsWith("0")) sReturn.remove(sReturn.length()-1,1); if(sReturn.endsWith(".")) sReturn.remove(sReturn.length()-1,1); } return sReturn; }
But, this is successively chaining a lot of string operations. The previously mentions methods are probably better.
@J.Hilk
Thank you for the code.
honestly, I solved the issue two or three days ago. When I found I can't rely on a function offered by Qt on this specific problem, I returned to my old friend, C++, and solved the issue using it.
But I appreciate your paying attention to the problem.