赞
踩
1. 不指定小数位数
- double value = 1.2345
- QString str = QString("%1").args(double value = 1.2345);
2. 指定小数位数
- double value = 1.2345
- QString str = QString::number(value, 'f', 2);
- //QString::number(double n, char format = 'g', int precision = 6)
- //Format Meaning
- //e format as [-]9.9e[+|-]999
- //E format as [-]9.9E[+|-]999
- //f format as [-]9.9
- //g use e or f format, whichever is the most concise
- //G use E or f format, whichever is the most concise
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。