summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/qintvalidator.3qt
blob: ad6fc60549138d1a31bada6046108aa260d54cad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
'\" t
.TH QIntValidator 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA.  All rights reserved.  See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QIntValidator \- Validator which ensures that a string contains a valid integer within a specified range
.SH SYNOPSIS
\fC#include <qvalidator.h>\fR
.PP
Inherits QValidator.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQIntValidator\fR ( QObject * parent, const char * name = 0 )"
.br
.ti -1c
.BI "\fBQIntValidator\fR ( int minimum, int maximum, QObject * parent, const char * name = 0 )"
.br
.ti -1c
.BI "\fB~QIntValidator\fR ()"
.br
.ti -1c
.BI "virtual QValidator::State \fBvalidate\fR ( QString & input, int & ) const"
.br
.ti -1c
.BI "void \fBsetBottom\fR ( int )"
.br
.ti -1c
.BI "void \fBsetTop\fR ( int )"
.br
.ti -1c
.BI "virtual void \fBsetRange\fR ( int bottom, int top )"
.br
.ti -1c
.BI "int \fBbottom\fR () const"
.br
.ti -1c
.BI "int \fBtop\fR () const"
.br
.in -1c
.SS "Properties"
.in +1c
.ti -1c
.BI "int \fBbottom\fR - the validator's lowest acceptable value"
.br
.ti -1c
.BI "int \fBtop\fR - the validator's highest acceptable value"
.br
.in -1c
.SH DESCRIPTION
The QIntValidator class provides a validator which ensures that a string contains a valid integer within a specified range.
.PP
Example of use:
.PP
.nf
.br
    QValidator* validator = new QIntValidator( 100, 999, this );
.br
    QLineEdit* edit = new QLineEdit( this );
.br
.br
    // the edit lineedit will only accept integers between 100 and 999
.br
    edit->setValidator( validator );
.br
.fi
.PP
Below we present some examples of validators. In practice they would normally be associated with a widget as in the example above.
.PP
.nf
.br
    QString str;
.br
    int pos = 0;
.br
    QIntValidator v( 100, 999, this );
.br
.br
    str = "1";
.br
    v.validate( str, pos );     // returns Intermediate
.br
    str = "12";
.br
    v.validate( str, pos );     // returns Intermediate
.br
.br
    str = "123";
.br
    v.validate( str, pos );     // returns Acceptable
.br
    str = "678";
.br
    v.validate( str, pos );     // returns Acceptable
.br
.br
    str = "1234";
.br
    v.validate( str, pos );     // returns Invalid
.br
    str = "-123";
.br
    v.validate( str, pos );     // returns Invalid
.br
    str = "abc";
.br
    v.validate( str, pos );     // returns Invalid
.br
    str = "12cm";
.br
    v.validate( str, pos );     // returns Invalid
.br
.fi
.PP
The minimum and maximum values are set in one call with setRange() or individually with setBottom() and setTop().
.PP
See also QDoubleValidator, QRegExpValidator, and Miscellaneous Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QIntValidator::QIntValidator ( QObject * parent, const char * name = 0 )"
Constructs a validator called \fIname\fR with parent \fIparent\fR, that accepts all integers.
.SH "QIntValidator::QIntValidator ( int minimum, int maximum, QObject * parent, const char * name = 0 )"
Constructs a validator called \fIname\fR with parent \fIparent\fR, that accepts integers from \fIminimum\fR to \fImaximum\fR inclusive.
.SH "QIntValidator::~QIntValidator ()"
Destroys the validator, freeing any resources allocated.
.SH "int QIntValidator::bottom () const"
Returns the validator's lowest acceptable value. See the "bottom" property for details.
.SH "void QIntValidator::setBottom ( int )"
Sets the validator's lowest acceptable value. See the "bottom" property for details.
.SH "void QIntValidator::setRange ( int bottom, int top )\fC [virtual]\fR"
Sets the range of the validator to only accept integers between \fIbottom\fR and \fItop\fR inclusive.
.SH "void QIntValidator::setTop ( int )"
Sets the validator's highest acceptable value. See the "top" property for details.
.SH "int QIntValidator::top () const"
Returns the validator's highest acceptable value. See the "top" property for details.
.SH "QValidator::State QIntValidator::validate ( QString & input, int & ) const\fC [virtual]\fR"
Returns Acceptable if the \fIinput\fR is an integer within the valid range, Intermediate if the \fIinput\fR is an integer outside the valid range and Invalid if the \fIinput\fR is not an integer.
.PP
Note: If the valid range consists of just positive integers (e.g. 32 - 100) and \fIinput\fR is a negative integer then Invalid is returned.
.PP
.nf
.br
    int pos = 0;
.br
    s = "abc";
.br
    v.validate( s, pos ); // returns Invalid
.br
.br
    s = "5";
.br
    v.validate( s, pos ); // returns Intermediate
.br
.br
    s = "50";
.br
    v.validate( s, pos ); // returns Valid
.br
.fi
.PP
Reimplemented from QValidator.
.SS "Property Documentation"
.SH "int bottom"
This property holds the validator's lowest acceptable value.
.PP
Set this property's value with setBottom() and get this property's value with bottom().
.PP
See also setRange().
.SH "int top"
This property holds the validator's highest acceptable value.
.PP
Set this property's value with setTop() and get this property's value with top().
.PP
See also setRange().

.SH "SEE ALSO"
.BR http://doc.trolltech.com/qintvalidator.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech. 
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (qintvalidator.3qt) and the Qt
version (3.3.8).