Do you mean something like this?
#include <QtGui>
{
public:
MyDoubleSpinBox
(QWidget* parent
= 0)
{
// force reformatting
setValue(value());
}
QString textFromValue
(double value
) const {
// the default implementation removes group separator characters
}
};
int main(int argc, char *argv[])
{
MyDoubleSpinBox spinBox;
spinBox.setRange(-999999, 999999);
spinBox.setValue(500000);
spinBox.show();
return a.exec();
}
#include <QtGui>
class MyDoubleSpinBox : public QDoubleSpinBox
{
public:
MyDoubleSpinBox(QWidget* parent = 0)
: QDoubleSpinBox(parent) { }
void focusOutEvent(QFocusEvent* event)
{
QDoubleSpinBox::focusOutEvent(event);
// force reformatting
setValue(value());
}
QString textFromValue(double value) const
{
// the default implementation removes group separator characters
return QLocale(QLocale::English).toString(value, 'f', decimals());
}
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyDoubleSpinBox spinBox;
spinBox.setRange(-999999, 999999);
spinBox.setValue(500000);
spinBox.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks