21#include <QRegularExpressionValidator> 
   22#include <QRegularExpression> 
   28const QString 
PERMISSIVE_DOUBLE = R
"([+\-%3]?[\d]{0,1000}([\.%1][\d]{0,1000})?([eE%4][+\-%3]?[\d]{0,%2})?)"; 
   31  : QRegularExpressionValidator( parent ) 
   32  , mMinimum( std::numeric_limits<qreal>::lowest() ) 
   33  , mMaximum( std::numeric_limits<qreal>::max() ) 
   38                                .arg( QLocale().negativeSign() )
 
   39                                .arg( QLocale().exponential() ) );
 
   40  setRegularExpression( reg );
 
   44  : QRegularExpressionValidator( parent )
 
   48  setRegularExpression( expression );
 
   52  : QRegularExpressionValidator( parent )
 
   59                                .arg( QLocale().negativeSign() )
 
   60                                .arg( QLocale().exponential() ) );
 
   61  setRegularExpression( reg );
 
   65  : QRegularExpressionValidator( parent )
 
   71                                .arg( QString::number( decimal ) )
 
   72                                .arg( QLocale().negativeSign() )
 
   73                                .arg( QLocale().exponential() ) );
 
   74  setRegularExpression( reg );
 
   78  : QRegularExpressionValidator( parent )
 
   79  , mMinimum( std::numeric_limits<qreal>::lowest() )
 
   80  , mMaximum( std::numeric_limits<qreal>::max() )
 
   84                                .arg( QString::number( decimal ) )
 
   85                                .arg( QLocale().negativeSign() )
 
   86                                .arg( QLocale().exponential() ) );
 
   87  setRegularExpression( reg );
 
   93                                .arg( QString::number( maxDecimals ) )
 
   94                                .arg( QLocale().negativeSign() )
 
   95                                .arg( QLocale().exponential() ) );
 
   96  setRegularExpression( reg );
 
  101  if ( input.isEmpty() )
 
  109    if ( regularExpression().match( input ).captured( 0 ) == input )
 
  115  if ( entered >= mMinimum && entered <= mMaximum && regularExpression().match( input ).captured( 0 ) == input )
 
  123  if ( input.isEmpty() )
 
  131    if ( regularExpression().match( input ).captured( 0 ) == input )
 
  137  if ( entered >= mMinimum && entered <= mMaximum && regularExpression().match( input ).captured( 0 ) == input )
 
  151  double value = QLocale().toDouble( input, ok );
 
  155    value = QLocale( QLocale::C ).toDouble( input, ok );
 
  158  if ( ! *ok && !( QLocale().numberOptions() & QLocale::NumberOption::OmitGroupSeparator ) )
 
  160    value = QLocale().toDouble( QString( input ).replace( QLocale().groupSeparator(), QString() ), ok );
 
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
 
QgsDoubleValidator(QObject *parent)
Constructor for QgsDoubleValidator.
 
QValidator::State validate(QString &input, int &) const override
 
void setMaxDecimals(int maxDecimals)
Sets the number of decimals accepted by the validator to maxDecimals.
 
const QString PERMISSIVE_DOUBLE