QSpinBox千分隔符 [英] QSpinBox thousand separator

查看:422
本文介绍了QSpinBox千分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用QSpinBox可以在用户输入时显示数字的千位分隔符
like 10,000
这是最好的方法吗?

QSpinBox 并重新实现 textFromValue ,它负责将值显示到纺纱箱窗口小部件。一个可能的实现可能如下:

  QString MySpinBox :: textFromValue(int value)
{
return this-> locale() - > toString(value);
}

使用 locale 是最好的方法,因为它会根据用户的设置显示分隔符。


With a QSpinBox is it possible to display the thousand separator of a number while user enter it like 10,000 Which is the best way to do that ?

解决方案

You could subclass QSpinBox and reimplement the textFromValue which is responsible for the display of the value to the spinbox widget. A possible implementation could be the following:

QString MySpinBox::textFromValue(int value)
{
   return this->locale()->toString(value);
}

Using locale is the best way since it will display the separator based on the user's settings.

这篇关于QSpinBox千分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆