Custom expression for QDoubleSpinBox
-
Hello,
I would need to change the format of QDoubleSpinBox in order to have a dot to separate integer from fractional part and commas to separate the integer part. E.g. if i have 1000000.456 where 1000000 is the integer part and 456 the decimal, I would like it to be formatted as
1,000,000.456
Would it be possible on a QDoubleSpinBox without subclassing it?
If I need to subclass it, is there a way to use it also as a QCustomBox model for the Qt designer in Qt Creator, since I am using Qt creator to generate complex widgets which include these spin boxes?Thanks for your help
-
Hello,
I would need to change the format of QDoubleSpinBox in order to have a dot to separate integer from fractional part and commas to separate the integer part. E.g. if i have 1000000.456 where 1000000 is the integer part and 456 the decimal, I would like it to be formatted as
1,000,000.456
Would it be possible on a QDoubleSpinBox without subclassing it?
If I need to subclass it, is there a way to use it also as a QCustomBox model for the Qt designer in Qt Creator, since I am using Qt creator to generate complex widgets which include these spin boxes?Thanks for your help
@Gaetano03
Every hit I can see indicates that you do need to subclassQDoubleSpinBox
to control its text format (QString textFromValue()
), e.g. https://stackoverflow.com/questions/54295639/how-to-set-qdoublespinbox-to-scientific-notation or https://stackoverflow.com/questions/27332700/how-to-change-text-format-of-qdoublespinbox .QCustomBox model
Don't know what that is. You could have it as a Qt Designer custom widget to use in Designer, but for this simple subclassing just using Designer's Promote... feature is simpler and should be adequate.
-
Seems like I achieved it using this
https://stackoverflow.com/questions/9274884/qspinbox-thousand-separator
if this can be of help to others.
Thanks!