QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
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
25
#include "qgis_gui.h"
26
#include "
qgis_sip.h
"
27
28
#include <QLocale>
29
#include <QRegularExpressionValidator>
30
31
class
QRegularExpression;
32
44
class
GUI_EXPORT
QgsDoubleValidator
:
public
QRegularExpressionValidator
45
{
46
Q_OBJECT
47
48
public
:
52
explicit
QgsDoubleValidator
( QObject *parent );
53
62
QgsDoubleValidator
(
const
QRegularExpression &expression,
double
bottom
,
double
top
, QObject *parent );
63
71
QgsDoubleValidator
(
double
bottom
,
double
top
, QObject *parent );
72
81
QgsDoubleValidator
(
double
bottom
,
double
top
,
int
decimal, QObject *parent );
82
90
QgsDoubleValidator
(
int
decimal, QObject *parent );
91
97
void
setMaxDecimals
(
int
maxDecimals );
98
99
100
QValidator::State
validate
( QString &input,
int
& )
const
override
SIP_SKIP
;
101
106
QValidator::State
validate
( QString &input )
const
;
107
113
static
double
toDouble
(
const
QString &input,
bool
*ok )
SIP_SKIP
;
114
120
static
double
toDouble
(
const
QString &input );
121
127
void
setBottom
(
double
bottom
) { mMinimum =
bottom
; }
128
134
void
setTop
(
double
top
) { mMaximum =
top
; }
135
141
virtual
void
setRange
(
double
bottom
,
double
top
)
142
{
143
mMinimum =
bottom
;
144
mMaximum =
top
;
145
}
146
151
double
bottom
()
const
{
return
mMinimum; }
152
157
double
top
()
const
{
return
mMaximum; }
158
159
private
:
160
// Disables copy constructing
161
Q_DISABLE_COPY(
QgsDoubleValidator
)
162
163
166
double
mMinimum;
167
171
double
mMaximum;
172
176
static
QRegularExpression createExpression(
int
decimals );
177
};
178
179
#endif
// QGSDOUBLEVALIDATOR_H
QgsDoubleValidator
A custom validator which allows entry of doubles in a locale-tolerant way.
Definition
qgsdoublevalidator.h:45
QgsDoubleValidator::toDouble
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
Definition
qgsdoublevalidator.cpp:143
QgsDoubleValidator::QgsDoubleValidator
QgsDoubleValidator(QObject *parent)
Constructor for QgsDoubleValidator.
Definition
qgsdoublevalidator.cpp:34
QgsDoubleValidator::top
double top() const
Returns top range limit.
Definition
qgsdoublevalidator.h:157
QgsDoubleValidator::setRange
virtual void setRange(double bottom, double top)
Set bottom and top range limits.
Definition
qgsdoublevalidator.h:141
QgsDoubleValidator::validate
QValidator::State validate(QString &input, int &) const override
Definition
qgsdoublevalidator.cpp:80
QgsDoubleValidator::setTop
void setTop(double top)
Set top range limit.
Definition
qgsdoublevalidator.h:134
QgsDoubleValidator::setMaxDecimals
void setMaxDecimals(int maxDecimals)
Sets the number of decimals accepted by the validator to maxDecimals.
Definition
qgsdoublevalidator.cpp:75
QgsDoubleValidator::bottom
double bottom() const
Returns top range limit.
Definition
qgsdoublevalidator.h:151
QgsDoubleValidator::setBottom
void setBottom(double bottom)
Set top range limit.
Definition
qgsdoublevalidator.h:127
qgis_sip.h
SIP_SKIP
#define SIP_SKIP
Definition
qgis_sip.h:138
Generated on
for QGIS API Documentation by
1.17.0