1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qvalidator.cpp:181 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>QIntValidator Class</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QIntValidator Class Reference</h1>
|
---|
33 |
|
---|
34 | <p>The QIntValidator class provides a validator which ensures
|
---|
35 | that a string contains a valid integer within a specified range.
|
---|
36 | <a href="#details">More...</a>
|
---|
37 | <p><tt>#include <<a href="qvalidator-h.html">qvalidator.h</a>></tt>
|
---|
38 | <p>Inherits <a href="qvalidator.html">QValidator</a>.
|
---|
39 | <p><a href="qintvalidator-members.html">List of all member functions.</a>
|
---|
40 | <h2>Public Members</h2>
|
---|
41 | <ul>
|
---|
42 | <li class=fn><a href="#QIntValidator"><b>QIntValidator</b></a> ( QObject * parent, const char * name = 0 )</li>
|
---|
43 | <li class=fn><a href="#QIntValidator-2"><b>QIntValidator</b></a> ( int minimum, int maximum, QObject * parent, const char * name = 0 )</li>
|
---|
44 | <li class=fn><a href="#~QIntValidator"><b>~QIntValidator</b></a> ()</li>
|
---|
45 | <li class=fn>virtual QValidator::State <a href="#validate"><b>validate</b></a> ( QString & input, int & ) const</li>
|
---|
46 | <li class=fn>void <a href="#setBottom"><b>setBottom</b></a> ( int )</li>
|
---|
47 | <li class=fn>void <a href="#setTop"><b>setTop</b></a> ( int )</li>
|
---|
48 | <li class=fn>virtual void <a href="#setRange"><b>setRange</b></a> ( int bottom, int top )</li>
|
---|
49 | <li class=fn>int <a href="#bottom"><b>bottom</b></a> () const</li>
|
---|
50 | <li class=fn>int <a href="#top"><b>top</b></a> () const</li>
|
---|
51 | </ul>
|
---|
52 | <h2>Properties</h2>
|
---|
53 | <ul>
|
---|
54 | <li class=fn>int <a href="#bottom-prop"><b>bottom</b></a> - the validator's lowest acceptable value</li>
|
---|
55 | <li class=fn>int <a href="#top-prop"><b>top</b></a> - the validator's highest acceptable value</li>
|
---|
56 | </ul>
|
---|
57 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
58 |
|
---|
59 |
|
---|
60 | The QIntValidator class provides a validator which ensures
|
---|
61 | that a string contains a valid integer within a specified range.
|
---|
62 | <p>
|
---|
63 | <p> Example of use:
|
---|
64 | <p> <pre>
|
---|
65 | <a href="qvalidator.html">QValidator</a>* validator = new QIntValidator( 100, 999, this );
|
---|
66 | <a href="qlineedit.html">QLineEdit</a>* edit = new <a href="qlineedit.html">QLineEdit</a>( this );
|
---|
67 |
|
---|
68 | // the edit lineedit will only accept integers between 100 and 999
|
---|
69 | edit-><a href="qlineedit.html#setValidator">setValidator</a>( validator );
|
---|
70 | </pre>
|
---|
71 |
|
---|
72 | <p> Below we present some examples of validators. In practice they would
|
---|
73 | normally be associated with a widget as in the example above.
|
---|
74 | <p> <pre>
|
---|
75 | <a href="qstring.html">QString</a> str;
|
---|
76 | int pos = 0;
|
---|
77 | QIntValidator v( 100, 999, this );
|
---|
78 |
|
---|
79 | str = "1";
|
---|
80 | v.<a href="#validate">validate</a>( str, pos ); // returns Intermediate
|
---|
81 | str = "12";
|
---|
82 | v.<a href="#validate">validate</a>( str, pos ); // returns Intermediate
|
---|
83 |
|
---|
84 | str = "123";
|
---|
85 | v.<a href="#validate">validate</a>( str, pos ); // returns Acceptable
|
---|
86 | str = "678";
|
---|
87 | v.<a href="#validate">validate</a>( str, pos ); // returns Acceptable
|
---|
88 |
|
---|
89 | str = "1234";
|
---|
90 | v.<a href="#validate">validate</a>( str, pos ); // returns Invalid
|
---|
91 | str = "-123";
|
---|
92 | v.<a href="#validate">validate</a>( str, pos ); // returns Invalid
|
---|
93 | str = "abc";
|
---|
94 | v.<a href="#validate">validate</a>( str, pos ); // returns Invalid
|
---|
95 | str = "12cm";
|
---|
96 | v.<a href="#validate">validate</a>( str, pos ); // returns Invalid
|
---|
97 | </pre>
|
---|
98 |
|
---|
99 | <p> The minimum and maximum values are set in one call with <a href="#setRange">setRange</a>()
|
---|
100 | or individually with <a href="#setBottom">setBottom</a>() and <a href="#setTop">setTop</a>().
|
---|
101 | <p> <p>See also <a href="qdoublevalidator.html">QDoubleValidator</a>, <a href="qregexpvalidator.html">QRegExpValidator</a>, and <a href="misc.html">Miscellaneous Classes</a>.
|
---|
102 |
|
---|
103 | <hr><h2>Member Function Documentation</h2>
|
---|
104 | <h3 class=fn><a name="QIntValidator"></a>QIntValidator::QIntValidator ( <a href="qobject.html">QObject</a> * parent, const char * name = 0 )
|
---|
105 | </h3>
|
---|
106 | Constructs a validator called <em>name</em> with parent <em>parent</em>, that
|
---|
107 | accepts all integers.
|
---|
108 |
|
---|
109 | <h3 class=fn><a name="QIntValidator-2"></a>QIntValidator::QIntValidator ( int minimum, int maximum, <a href="qobject.html">QObject</a> * parent, const char * name = 0 )
|
---|
110 | </h3>
|
---|
111 | Constructs a validator called <em>name</em> with parent <em>parent</em>, that
|
---|
112 | accepts integers from <em>minimum</em> to <em>maximum</em> inclusive.
|
---|
113 |
|
---|
114 | <h3 class=fn><a name="~QIntValidator"></a>QIntValidator::~QIntValidator ()
|
---|
115 | </h3>
|
---|
116 | Destroys the validator, freeing any resources allocated.
|
---|
117 |
|
---|
118 | <h3 class=fn>int <a name="bottom"></a>QIntValidator::bottom () const
|
---|
119 | </h3><p>Returns the validator's lowest acceptable value.
|
---|
120 | See the <a href="qintvalidator.html#bottom-prop">"bottom"</a> property for details.
|
---|
121 | <h3 class=fn>void <a name="setBottom"></a>QIntValidator::setBottom ( int )
|
---|
122 | </h3><p>Sets the validator's lowest acceptable value.
|
---|
123 | See the <a href="qintvalidator.html#bottom-prop">"bottom"</a> property for details.
|
---|
124 | <h3 class=fn>void <a name="setRange"></a>QIntValidator::setRange ( int bottom, int top )<tt> [virtual]</tt>
|
---|
125 | </h3>
|
---|
126 | Sets the range of the validator to only accept integers between <em>bottom</em> and <em>top</em> inclusive.
|
---|
127 |
|
---|
128 | <h3 class=fn>void <a name="setTop"></a>QIntValidator::setTop ( int )
|
---|
129 | </h3><p>Sets the validator's highest acceptable value.
|
---|
130 | See the <a href="qintvalidator.html#top-prop">"top"</a> property for details.
|
---|
131 | <h3 class=fn>int <a name="top"></a>QIntValidator::top () const
|
---|
132 | </h3><p>Returns the validator's highest acceptable value.
|
---|
133 | See the <a href="qintvalidator.html#top-prop">"top"</a> property for details.
|
---|
134 | <h3 class=fn><a href="qvalidator.html#State-enum">QValidator::State</a> <a name="validate"></a>QIntValidator::validate ( <a href="qstring.html">QString</a> & input, int & ) const<tt> [virtual]</tt>
|
---|
135 | </h3>
|
---|
136 | Returns <a href="qvalidator.html#State-enum">Acceptable</a> if the <em>input</em> is an integer within the
|
---|
137 | valid range, <a href="qvalidator.html#State-enum">Intermediate</a> if the <em>input</em> is an integer outside
|
---|
138 | the valid range and <a href="qvalidator.html#State-enum">Invalid</a> if the <em>input</em> is not an integer.
|
---|
139 | <p> Note: If the valid range consists of just positive integers (e.g. 32 - 100)
|
---|
140 | and <em>input</em> is a negative integer then Invalid is returned.
|
---|
141 | <p> <pre>
|
---|
142 | int pos = 0;
|
---|
143 | s = "abc";
|
---|
144 | v.validate( s, pos ); // returns Invalid
|
---|
145 |
|
---|
146 | s = "5";
|
---|
147 | v.validate( s, pos ); // returns Intermediate
|
---|
148 |
|
---|
149 | s = "50";
|
---|
150 | v.validate( s, pos ); // returns Valid
|
---|
151 | </pre>
|
---|
152 |
|
---|
153 |
|
---|
154 | <p>Reimplemented from <a href="qvalidator.html#validate">QValidator</a>.
|
---|
155 | <hr><h2>Property Documentation</h2>
|
---|
156 | <h3 class=fn>int <a name="bottom-prop"></a>bottom</h3>
|
---|
157 | <p>This property holds the validator's lowest acceptable value.
|
---|
158 | <p>Set this property's value with <a href="#setBottom">setBottom</a>() and get this property's value with <a href="#bottom">bottom</a>().
|
---|
159 | <p><p>See also <a href="#setRange">setRange</a>().
|
---|
160 |
|
---|
161 | <h3 class=fn>int <a name="top-prop"></a>top</h3>
|
---|
162 | <p>This property holds the validator's highest acceptable value.
|
---|
163 | <p>Set this property's value with <a href="#setTop">setTop</a>() and get this property's value with <a href="#top">top</a>().
|
---|
164 | <p><p>See also <a href="#setRange">setRange</a>().
|
---|
165 |
|
---|
166 | <!-- eof -->
|
---|
167 | <hr><p>
|
---|
168 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
169 | Copyright © 1995-2007
|
---|
170 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
171 | <table width=100% cellspacing=0 border=0><tr>
|
---|
172 | <td>Copyright © 2007
|
---|
173 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
174 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
175 | </table></div></address></body>
|
---|
176 | </html>
|
---|