QSpinBox 千位分隔符
使用 QSpinBox 可以在用户输入数字时显示数字的千位分隔符 大约10,000 哪种方法最好?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我知道这已经晚了,但这可能对其他人有帮助。我用它来更新千位分隔符
ui->doubleSpinBox->setGroupSeparatorShown(true);
或
以 ui
在我的 QDialog 表单中我使用了这个要使用千位分隔符更新金额,
编辑:
i know this is late but this may help other people. i used this to update the thousand separator
ui->doubleSpinBox->setGroupSeparatorShown(true);
or
set the property it in the form ui
In my QDialog Form i used this to update the amount with thousand separator,
EDIT:
您可以继承
QSpinBox
并重新实现textFromValue
负责将值显示到旋转框小部件。可能的实现如下:使用 locale 是最好的方法,因为它将根据用户的设置显示分隔符。
You could subclass
QSpinBox
and reimplement thetextFromValue
which is responsible for the display of the value to the spinbox widget. A possible implementation could be the following:Using locale is the best way since it will display the separator based on the user's settings.