Reputation: 83
I have a number that is displayed in a QSpinBox
and QLabel
like this:
3570000
But I want it to look like this:
3,570,000
How must I do it?
Upvotes: 1
Views: 204
Reputation: 1329
Your best bet would be to create your own subclass of QSpinBox
and override the valueFromText
and textFromValue
functions. See Subclassing QSpinBox
for more info.
Upvotes: 1
Reputation: 2444
Since Qt 5.3 this is a feature supported by QAbstractSpinBox
, from which QSpinBox
is derived, which defaults to false
. Just call
QSpinBox::setGroupSeparatorShown(true);`
after you've created the QSpinBox
.
If you are using a version of Qt prior to Qt 5.3, then subclassing is the only choice.
Upvotes: 5