float型数据保持小数点两位小数并装成QString

flat a = 12.123456;
QString str = QString::asprintf(“%.2f,”, a);

printf(“str = %s\n”,str.tolocal8Bit().data());

输出结果:str = 12.12

你可能感兴趣的:(数据转换)