QGIS API Documentation  3.22.4-Białowieża (ce8e65e95e)
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 <QRegularExpressionValidator>
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 
94  void setMaxDecimals( int maxDecimals );
95 
96 
97  QValidator::State validate( QString &input, int & ) const override SIP_SKIP;
98 
103  QValidator::State validate( QString &input ) const;
104 
110  static double toDouble( const QString &input, bool *ok ) SIP_SKIP;
111 
117  static double toDouble( const QString &input );
118 
124  void setBottom( double bottom ) { mMinimum = bottom; }
125 
131  void setTop( double top ) { mMaximum = top; }
132 
138  virtual void setRange( double bottom, double top )
139  {
140  mMinimum = bottom;
141  mMaximum = top;
142  }
143 
148  double bottom() const { return mMinimum; }
149 
154  double top() const { return mMaximum; }
155 
156  private:
157  // Disables copy constructing
158  Q_DISABLE_COPY( QgsDoubleValidator )
159 
160 
163  double mMinimum;
164 
168  double mMaximum;
169 };
170 
171 #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