Qt中把浮点数转为QString


double d = 1.2222;
QString.setNum(d,'f',2);   // 1.22

QString &QString::setNum(double n, char format = 'g', int precision = 6)
This is an overloaded function.
Sets the string to the printed value of n, formatted according to the given format and precision, and returns a reference to the string.
The format can be 'e', 'E', 'f', 'g' or 'G' (see Argument Formats for an explanation of the formats).


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM