Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qvalidator.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
3
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
// Qt-Security score:significant reason:default
5
6
#
ifndef
QVALIDATOR_H
7
#
define
QVALIDATOR_H
8
9
#
include
<
QtGui
/
qtguiglobal
.
h
>
10
#
include
<
QtCore
/
qobject
.
h
>
11
#
include
<
QtCore
/
qstring
.
h
>
12
#
if
QT_CONFIG
(
regularexpression
)
13
#
include
<
QtCore
/
qregularexpression
.
h
>
14
#
endif
15
#
include
<
QtCore
/
qlocale
.
h
>
16
17
QT_BEGIN_NAMESPACE
18
19
20
#
ifndef
QT_NO_VALIDATOR
21
22
class
QValidatorPrivate;
23
24
class
Q_GUI_EXPORT
QValidator
:
public
QObject
25
{
26
Q_OBJECT
27
public
:
28
explicit
QValidator(QObject * parent =
nullptr
);
29
~QValidator();
30
31
enum
State {
32
Invalid,
33
Intermediate,
34
Acceptable
35
};
36
Q_ENUM(State)
37
38
void
setLocale(
const
QLocale &locale);
39
QLocale locale()
const
;
40
41
virtual
State validate(QString &,
int
&)
const
= 0;
42
virtual
void
fixup(QString &)
const
;
43
44
Q_SIGNALS:
45
void
changed();
46
47
protected
:
48
QValidator(QObjectPrivate &d, QObject *parent);
49
QValidator(QValidatorPrivate &d, QObject *parent);
50
51
private
:
52
Q_DISABLE_COPY(QValidator)
53
Q_DECLARE_PRIVATE(QValidator)
54
};
55
56
class
Q_GUI_EXPORT
QIntValidator
:
public
QValidator
57
{
58
Q_OBJECT
59
Q_PROPERTY(
int
bottom READ bottom WRITE setBottom NOTIFY bottomChanged)
60
Q_PROPERTY(
int
top READ top WRITE setTop NOTIFY topChanged)
61
62
public
:
63
explicit
QIntValidator(QObject * parent =
nullptr
);
64
QIntValidator(
int
bottom,
int
top, QObject *parent =
nullptr
);
65
~QIntValidator();
66
67
QValidator::State validate(QString &,
int
&)
const
override;
68
void
fixup(QString &input)
const
override;
69
70
void
setBottom(
int
);
71
void
setTop(
int
);
72
void
setRange(
int
bottom,
int
top);
73
74
int
bottom()
const
{
return
b; }
75
int
top()
const
{
return
t; }
76
Q_SIGNALS:
77
void
bottomChanged(
int
bottom);
78
void
topChanged(
int
top);
79
80
private
:
81
Q_DISABLE_COPY(QIntValidator)
82
83
int
b;
84
int
t;
85
};
86
87
class
QDoubleValidatorPrivate
;
88
89
class
Q_GUI_EXPORT
QDoubleValidator
:
public
QValidator
90
{
91
Q_OBJECT
92
Q_PROPERTY(
double
bottom READ bottom WRITE setBottom NOTIFY bottomChanged)
93
Q_PROPERTY(
double
top READ top WRITE setTop NOTIFY topChanged)
94
Q_PROPERTY(
int
decimals READ decimals WRITE setDecimals NOTIFY decimalsChanged)
95
Q_PROPERTY(Notation notation READ notation WRITE setNotation NOTIFY notationChanged)
96
97
public
:
98
explicit
QDoubleValidator(QObject * parent =
nullptr
);
99
QDoubleValidator(
double
bottom,
double
top,
int
decimals, QObject *parent =
nullptr
);
100
~QDoubleValidator();
101
102
enum
Notation {
103
StandardNotation,
104
ScientificNotation
105
};
106
Q_ENUM(Notation)
107
QValidator::State validate(QString &,
int
&)
const
override;
108
void
fixup(QString &input)
const
override;
109
110
void
setRange(
double
bottom,
double
top,
int
decimals);
111
void
setRange(
double
bottom,
double
top);
112
void
setBottom(
double
);
113
void
setTop(
double
);
114
void
setDecimals(
int
);
115
void
setNotation(Notation);
116
117
double
bottom()
const
{
return
b; }
118
double
top()
const
{
return
t; }
119
int
decimals()
const
{
return
dec; }
120
Notation notation()
const
;
121
122
Q_SIGNALS:
123
void
bottomChanged(
double
bottom);
124
void
topChanged(
double
top);
125
void
decimalsChanged(
int
decimals);
126
void
notationChanged(QDoubleValidator::Notation notation);
127
128
private
:
129
Q_DECLARE_PRIVATE(QDoubleValidator)
130
Q_DISABLE_COPY(QDoubleValidator)
131
132
double
b;
133
double
t;
134
int
dec;
135
};
136
137
#
if
QT_CONFIG
(
regularexpression
)
138
139
class
QRegularExpressionValidatorPrivate;
140
141
class
Q_GUI_EXPORT QRegularExpressionValidator :
public
QValidator
142
{
143
Q_OBJECT
144
Q_PROPERTY(QRegularExpression regularExpression READ regularExpression WRITE setRegularExpression NOTIFY regularExpressionChanged)
145
146
public
:
147
explicit
QRegularExpressionValidator(QObject *parent =
nullptr
);
148
explicit
QRegularExpressionValidator(
const
QRegularExpression &re, QObject *parent =
nullptr
);
149
~QRegularExpressionValidator();
150
151
QValidator::State validate(QString &input,
int
&pos)
const
override;
152
153
QRegularExpression regularExpression()
const
;
154
155
public
Q_SLOTS:
156
void
setRegularExpression(
const
QRegularExpression &re);
157
158
Q_SIGNALS:
159
void
regularExpressionChanged(
const
QRegularExpression &re);
160
161
private
:
162
Q_DISABLE_COPY(QRegularExpressionValidator)
163
Q_DECLARE_PRIVATE(QRegularExpressionValidator)
164
};
165
166
#
endif
// QT_CONFIG(regularexpression)
167
168
#
endif
// QT_NO_VALIDATOR
169
170
QT_END_NAMESPACE
171
172
#
endif
// QVALIDATOR_H
QDoubleValidatorPrivate
Definition
qvalidator.cpp:509
QDoubleValidatorPrivate::fixupWithLocale
void fixupWithLocale(QString &input, QLocaleData::NumberMode numMode, const QLocale &locale) const
Definition
qvalidator.cpp:724
QDoubleValidator
The QDoubleValidator class provides range checking of floating-point numbers.
Definition
qvalidator.h:90
QIntValidator
The QIntValidator class provides a validator that ensures a string contains a valid integer within a ...
Definition
qvalidator.h:57
QValidator
The QValidator class provides validation of input text.
Definition
qvalidator.h:25
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
LLONG_MAX
#define LLONG_MAX
Definition
qlocale_tools.cpp:33
initialResultCheck
static std::optional< QValidator::State > initialResultCheck(T min, T max, const QLocaleData::ParsingResult &result)
Definition
qvalidator.cpp:363
hasMoreIntegerDigits
static bool hasMoreIntegerDigits(double value, double bound)
Definition
qvalidator.cpp:352
qtbase
src
gui
util
qvalidator.h
Generated on
for Qt by
1.18.0