概述
直接上代码,下面是示例:
示例一
float up = 23.45;
QString str = QString::number(up ,'f',2);
- 1
- 2
示例二
float up = 23.45;
QString str = QString::asprintf("%.2f",up);
- 1
- 2
示例三
float up = 23.45;
QString str;
str = str.setNum(up,'f',2);
- 1
- 2
- 3
示例四
float up = 23.45;
QString str;
str = str.sprintf("%.2f",up);
- 1
- 2
- 3
</article>