QT double 转换为QString的方法

1. 不指定小数位数

double value = 1.2345
QString str = QString("%1").args(double value = 1.2345);
wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

 


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
wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

 

 

 


 

 

你可能感兴趣的:(Qt学习)