QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsdoublevalidator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdoublevalidator.h - description
3  -------------------
4  begin : June 2020
5  copyright : (C) 2020 by Sebastien Peillet
6  email : [email protected]
7 
8  adapted version of Qgslonglongvalidator + QgsFieldValidator
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 
20 #ifndef QGSDOUBLEVALIDATOR_H
21 #define QGSDOUBLEVALIDATOR_H
22 
23 #include <limits>
24 #include <QRegExpValidator>
25 #include <QLocale>
26 #include "qgis_gui.h"
27 #include "qgis_sip.h"
28 
29 class QRegularExpression;
30 
40 class GUI_EXPORT QgsDoubleValidator : public QRegularExpressionValidator
41 {
42  Q_OBJECT
43 
44  public:
45 
49  explicit QgsDoubleValidator( QObject *parent );
50 
59  QgsDoubleValidator( const QRegularExpression &expression, double bottom, double top, QObject *parent );
60 
68  QgsDoubleValidator( double bottom, double top, QObject *parent );
69 
78  QgsDoubleValidator( double bottom, double top, int decimal, QObject *parent );
79 
87  QgsDoubleValidator( int decimal, QObject *parent );
88 
89  QValidator::State validate( QString &input, int & ) const override SIP_SKIP;
90 
95  QValidator::State validate( QString &input ) const;
96 
102  static double toDouble( const QString &input, bool *ok ) SIP_SKIP;
103 
109  static double toDouble( const QString &input );
110 
116  void setBottom( double bottom ) { mMinimum = bottom; }
117 
123  void setTop( double top ) { mMaximum = top; }
124 
130  virtual void setRange( double bottom, double top )
131  {
132  mMinimum = bottom;
133  mMaximum = top;
134  }
135 
140  double bottom() const { return mMinimum; }
141 
146  double top() const { return mMaximum; }
147 
148  private:
149  // Disables copy constructing
150  Q_DISABLE_COPY( QgsDoubleValidator )
151 
152 
155  double mMinimum;
156 
160  double mMaximum;
161 };
162 
163 #endif // QGSDOUBLEVALIDATOR_H
QgsDoubleValidator is a QLineEdit Validator that combines QDoubleValidator and QRegularExpressionVali...
double top() const
Returns top range limit.
virtual void setRange(double bottom, double top)
Set bottom and top range limits.
void setTop(double top)
Set top range limit.
double bottom() const
Returns top range limit.
void setBottom(double bottom)
Set top range limit.
#define SIP_SKIP
Definition: qgis_sip.h:126