qt带小数点的数字串显示,Qt-自定义小数点和千位分隔符
How can I convert a number (double) to string, with custom decimal point and thousand separator chars?
I've seen QLocale, but I don't want to choose the localization country, but rather specify my own decimal point and thousand separator chars.
Thanks
解決方案
Qt doesn't support custom locale. But to deal with just group and decimal point characters is trivial:
const QLocale & cLocale = QLocale::c();
QString ss = cLocale.toString(yourDoubleNumber, 'f');
ss.replace(cLocale.groupSeparator(), yourGroupChar);
ss.replace(cLocale.decimalPoint(), yourDecimalPointChar);
BTW, spbots' question is not irrelevant. More detail about the goal always helps and it could lead to different approach that may serve you better.
總結(jié)
以上是生活随笔為你收集整理的qt带小数点的数字串显示,Qt-自定义小数点和千位分隔符的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 优良中差五个等级英文表达_25道题测出你
- 下一篇: group by 将null放到其他_为