QGIS API Documentation 3.43.0-Master (b60ef06885e)
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 : sebastien.peillet@oslandia.com
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
29class QRegularExpression;
30
42class GUI_EXPORT QgsDoubleValidator : public QRegularExpressionValidator
43{
44 Q_OBJECT
45
46 public:
50 explicit QgsDoubleValidator( QObject *parent );
51
60 QgsDoubleValidator( const QRegularExpression &expression, double bottom, double top, QObject *parent );
61
69 QgsDoubleValidator( double bottom, double top, QObject *parent );
70
79 QgsDoubleValidator( double bottom, double top, int decimal, QObject *parent );
80
88 QgsDoubleValidator( int decimal, QObject *parent );
89
95 void setMaxDecimals( int maxDecimals );
96
97
98 QValidator::State validate( QString &input, int & ) const override SIP_SKIP;
99
104 QValidator::State validate( QString &input ) const;
105
111 static double toDouble( const QString &input, bool *ok ) SIP_SKIP;
112
118 static double toDouble( const QString &input );
119
125 void setBottom( double bottom ) { mMinimum = bottom; }
126
132 void setTop( double top ) { mMaximum = top; }
133
139 virtual void setRange( double bottom, double top )
140 {
141 mMinimum = bottom;
142 mMaximum = top;
143 }
144
149 double bottom() const { return mMinimum; }
150
155 double top() const { return mMaximum; }
156
157 private:
158 // Disables copy constructing
159 Q_DISABLE_COPY( QgsDoubleValidator )
160
161
164 double mMinimum;
165
169 double mMaximum;
170};
171
172#endif // QGSDOUBLEVALIDATOR_H
A custom validator which allows entry of doubles in a locale-tolerant way.
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