21 #include <QRegExpValidator>
27 const QString
PERMISSIVE_DOUBLE = R
"(-?[\d]{0,1000}([\.%1][\d]{0,1000})?(e[+-]?[\d]{0,%2})?)";
30 : QRegularExpressionValidator( parent )
31 , mMinimum( std::numeric_limits<qreal>::min() )
32 , mMaximum( std::numeric_limits<qreal>::max() )
35 QRegularExpression reg(
PERMISSIVE_DOUBLE.arg( locale().decimalPoint() ).arg( 1000 ) );
36 setRegularExpression( reg );
40 : QRegularExpressionValidator( parent )
44 setRegularExpression( expression );
48 : QRegularExpressionValidator( parent )
53 QRegularExpression reg(
PERMISSIVE_DOUBLE.arg( locale().decimalPoint() ).arg( 1000 ) );
54 setRegularExpression( reg );
58 : QRegularExpressionValidator( parent )
63 QRegularExpression reg(
PERMISSIVE_DOUBLE.arg( locale().decimalPoint() ).arg( QString::number( decimal ) ) );
64 setRegularExpression( reg );
69 if ( input.isEmpty() )
77 if ( regularExpression().match( input ).captured( 0 ) == input )
83 if ( entered >= mMinimum && entered <= mMaximum && regularExpression().match( input ).captured( 0 ) == input )
91 if ( input.isEmpty() )
99 if ( regularExpression().match( input ).captured( 0 ) == input )
105 if ( entered >= mMinimum && entered <= mMaximum && regularExpression().match( input ).captured( 0 ) == input )
114 double value = QLocale().toDouble( input, &ok );
117 value = QLocale( QLocale::C ).toDouble( input, &ok );
124 double value = QLocale().toDouble( input, ok );
128 value = QLocale( QLocale::C ).toDouble( input, ok );