From 0c083832bb83bd9929f4d6316c0eaa4fb3c9956a Mon Sep 17 00:00:00 2001 From: san Date: Thu, 15 Apr 2010 13:45:42 +0000 Subject: [PATCH] Issue 0020580: disable strict min/max checking of manually entered text by default, to make the spin box more user-friendly --- src/Qtx/QtxDoubleSpinBox.cxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Qtx/QtxDoubleSpinBox.cxx b/src/Qtx/QtxDoubleSpinBox.cxx index 579509e92..15fbf1355 100644 --- a/src/Qtx/QtxDoubleSpinBox.cxx +++ b/src/Qtx/QtxDoubleSpinBox.cxx @@ -26,6 +26,7 @@ #include #include +#include #include @@ -320,12 +321,17 @@ QValidator::State QtxDoubleSpinBox::validate( QString& str, int& pos ) const } // Treat values ouside (min; max) range as Invalid + // This check is enabled by assigning "strict_validity_check" dynamic property + // with value "true" to the spin box instance. if ( state == QValidator::Intermediate ){ bool isOk; double val = str.toDouble( &isOk ); if ( isOk ){ - if ( val < minimum() || val > maximum() ) - state = QValidator::Invalid; + QVariant propVal = property( "strict_validity_check" ); + if ( propVal.isValid() && propVal.canConvert( QVariant::Bool ) && propVal.toBool() ){ + if ( val < minimum() || val > maximum() ) + state = QValidator::Invalid; + } } else if ( myPrecision < 0 ){ // Consider too large negative exponent as Invalid -- 2.39.2