当前位置:   article > 正文

QT double 转换为QString的方法_qt double转qstring

qt double转qstring

1. 不指定小数位数

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

 


2. 指定小数位数

 

  1. double value = 1.2345
  2. QString str = QString::number(value, 'f', 2);
  3. //QString::number(double n, char format = 'g', int precision = 6)
  4. //Format Meaning
  5. //e format as [-]9.9e[+|-]999
  6. //E format as [-]9.9E[+|-]999
  7. //f format as [-]9.9
  8. //g use e or f format, whichever is the most concise
  9. //G use E or f format, whichever is the most concise
wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

 

 

 


 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/107742
推荐阅读
相关标签
  

闽ICP备14008679号