1QIntValidator(3qt) QIntValidator(3qt)
2
3
4
6 QIntValidator - Validator which ensures that a string contains a valid
7 integer within a specified range
8
10 #include <qvalidator.h>
11
12 Inherits QValidator.
13
14 Public Members
15 QIntValidator ( QObject * parent, const char * name = 0 )
16 QIntValidator ( int minimum, int maximum, QObject * parent, const char
17 * name = 0 )
18 ~QIntValidator ()
19 virtual QValidator::State validate ( QString & input, int & ) const
20 void setBottom ( int )
21 void setTop ( int )
22 virtual void setRange ( int bottom, int top )
23 int bottom () const
24 int top () const
25
26 Properties
27 int bottom - the validator's lowest acceptable value
28 int top - the validator's highest acceptable value
29
31 The QIntValidator class provides a validator which ensures that a
32 string contains a valid integer within a specified range.
33
34 Example of use:
35
36 QValidator* validator = new QIntValidator( 100, 999, this );
37 QLineEdit* edit = new QLineEdit( this );
38 // the edit lineedit will only accept integers between 100 and 999
39 edit->setValidator( validator );
40
41 Below we present some examples of validators. In practice they would
42 normally be associated with a widget as in the example above.
43
44 QString str;
45 int pos = 0;
46 QIntValidator v( 100, 999, this );
47 str = "1";
48 v.validate( str, pos ); // returns Intermediate
49 str = "12";
50 v.validate( str, pos ); // returns Intermediate
51 str = "123";
52 v.validate( str, pos ); // returns Acceptable
53 str = "678";
54 v.validate( str, pos ); // returns Acceptable
55 str = "1234";
56 v.validate( str, pos ); // returns Invalid
57 str = "-123";
58 v.validate( str, pos ); // returns Invalid
59 str = "abc";
60 v.validate( str, pos ); // returns Invalid
61 str = "12cm";
62 v.validate( str, pos ); // returns Invalid
63
64 The minimum and maximum values are set in one call with setRange() or
65 individually with setBottom() and setTop().
66
67 See also QDoubleValidator, QRegExpValidator, and Miscellaneous Classes.
68
71 Constructs a validator called name with parent parent, that accepts all
72 integers.
73
75 const char * name = 0 )
76 Constructs a validator called name with parent parent, that accepts
77 integers from minimum to maximum inclusive.
78
80 Destroys the validator, freeing any resources allocated.
81
83 Returns the validator's lowest acceptable value. See the "bottom"
84 property for details.
85
87 Sets the validator's lowest acceptable value. See the "bottom" property
88 for details.
89
91 Sets the range of the validator to only accept integers between bottom
92 and top inclusive.
93
95 Sets the validator's highest acceptable value. See the "top" property
96 for details.
97
99 Returns the validator's highest acceptable value. See the "top"
100 property for details.
101
103 [virtual]
104 Returns Acceptable if the input is an integer within the valid range,
105 Intermediate if the input is an integer outside the valid range and
106 Invalid if the input is not an integer.
107
108 Note: If the valid range consists of just positive integers (e.g. 32 -
109 100) and input is a negative integer then Invalid is returned.
110
111 int pos = 0;
112 s = "abc";
113 v.validate( s, pos ); // returns Invalid
114 s = "5";
115 v.validate( s, pos ); // returns Intermediate
116 s = "50";
117 v.validate( s, pos ); // returns Valid
118
119 Reimplemented from QValidator.
120
121 Property Documentation
123 This property holds the validator's lowest acceptable value.
124
125 Set this property's value with setBottom() and get this property's
126 value with bottom().
127
128 See also setRange().
129
131 This property holds the validator's highest acceptable value.
132
133 Set this property's value with setTop() and get this property's value
134 with top().
135
136 See also setRange().
137
138
140 http://doc.trolltech.com/qintvalidator.html
141 http://www.trolltech.com/faq/tech.html
142
144 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
145 license file included in the distribution for a complete license
146 statement.
147
149 Generated automatically from the source code.
150
152 If you find a bug in Qt, please report it as described in
153 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
154 help you. Thank you.
155
156 The definitive Qt documentation is provided in HTML format; it is
157 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
158 web browser. This man page is provided as a convenience for those users
159 who prefer man pages, although this format is not officially supported
160 by Trolltech.
161
162 If you find errors in this manual page, please report them to qt-
163 bugs@trolltech.com. Please include the name of the manual page
164 (qintvalidator.3qt) and the Qt version (3.3.8).
165
166
167
168Trolltech AS 2 February 2007 QIntValidator(3qt)