fix DoubleEdit with Qt6

- let the user add as many digits as wanted (using -1 in setRange)
- use standard notation, not scientific (which was the default)
- comment QDoubleValidator::fixup that for some reason blocks the edition of the field
This commit is contained in:
Jane Tournois 2023-12-01 10:23:44 +01:00
parent 642ea59de7
commit 1ca77d32af
1 changed files with 3 additions and 2 deletions

View File

@ -9,13 +9,14 @@ public:
: QDoubleValidator(parent) : QDoubleValidator(parent)
{ {
setLocale(QLocale::C); setLocale(QLocale::C);
setNotation(QDoubleValidator::StandardNotation);
} }
void fixup ( QString & input ) const void fixup ( QString & input ) const
{ {
input.replace(".", locale().decimalPoint()); input.replace(".", locale().decimalPoint());
input.replace(",", locale().decimalPoint()); input.replace(",", locale().decimalPoint());
QDoubleValidator::fixup(input); // QDoubleValidator::fixup(input);
} }
QValidator::State validate ( QString & input, int & pos ) const QValidator::State validate ( QString & input, int & pos ) const
{ {
@ -59,7 +60,7 @@ public:
void DoubleEdit::setRange(double rmin, double rmax) void DoubleEdit::setRange(double rmin, double rmax)
{ {
this->validator->setRange(rmin, rmax, this->validator->decimals()); this->validator->setRange(rmin, rmax, -1);
} }
double DoubleEdit::getValue() double DoubleEdit::getValue()