One way is inherit from QDoubleSpinBox and override the respective methods as follows in this pseudo code:
main.cpp
#include <QDoubleSpinBox>
#include <QApplication>
class MySpinBox : public QDoubleSpinBox
{
Q_OBJECT
public:
explicit MySpinBox(QWidget *parent = 0) : QDoubleSpinBox(parent) {}
double valueFromText(const QString & text) const
{
QString valueText = text;
valueText.chop(1);
valueText.replace("°", ".");
return valueText.toFloat();
}
QString textFromValue(double value) const
{
QString valueText = QString::number(value);
valueText.replace(".", "°");
valueText.append(".");
return valueText;
}
};
#include "main.moc"
int main(int argc, char **argv)
{
QApplication application(argc, argv);
MySpinBox mySpinBox;
mySpinBox.show();
return application.exec();
}
main.pro
TEMPLATE = app
TARGET = main
QT += widgets
SOURCES += main.cpp
Build and Run
qmake && make && ./main
Disclaimer: even though it looks like a compiling code, it does not work, but shows the concept.