QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
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
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
40class GUI_EXPORT QgsDoubleValidator : public QRegularExpressionValidator
41{
42 Q_OBJECT
43
44 public:
48 explicit QgsDoubleValidator( QObject *parent );
49
58 QgsDoubleValidator( const QRegularExpression &expression, double bottom, double top, QObject *parent );
59
67 QgsDoubleValidator( double bottom, double top, QObject *parent );
68
77 QgsDoubleValidator( double bottom, double top, int decimal, QObject *parent );
78
86 QgsDoubleValidator( int decimal, QObject *parent );
87
93 void setMaxDecimals( int maxDecimals );
94
95
96 QValidator::State validate( QString &input, int & ) const override SIP_SKIP;
97
102 QValidator::State validate( QString &input ) const;
103
109 static double toDouble( const QString &input, bool *ok ) SIP_SKIP;
110
116 static double toDouble( const QString &input );
117
123 void setBottom( double bottom ) { mMinimum = bottom; }
124
130 void setTop( double top ) { mMaximum = top; }
131
137 virtual void setRange( double bottom, double top )
138 {
139 mMinimum = bottom;
140 mMaximum = top;
141 }
142
147 double bottom() const { return mMinimum; }
148
153 double top() const { return mMaximum; }
154
155 private:
156 // Disables copy constructing
157 Q_DISABLE_COPY( QgsDoubleValidator )
158
159
162 double mMinimum;
163
167 double mMaximum;
168};
169
170#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