File: qintvalidator.html

package info (click to toggle)
python-qt4 4.0.1-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 18,632 kB
  • ctags: 2,639
  • sloc: python: 29,409; sh: 5,646; cpp: 3,168; xml: 149; makefile: 109
file content (65 lines) | stat: -rw-r--r-- 6,686 bytes parent folder | download
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
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QIntValidator Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QIntValidator Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QIntValidator class provides a validator that ensures a string contains a valid integer within a specified range. <a href="#details">More...</a></p>
<p>Inherits <a href="qvalidator.html">QValidator</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qintvalidator.html#QIntValidator">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>)</li><li><div class="fn" /><b><a href="qintvalidator.html#QIntValidator-2">__init__</a></b> (<i>self</i>, int&#160;<i>bottom</i>, int&#160;<i>top</i>, QObject&#160;<i>parent</i>)</li><li><div class="fn" />int <b><a href="qintvalidator.html#bottom">bottom</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qintvalidator.html#setBottom">setBottom</a></b> (<i>self</i>, int)</li><li><div class="fn" /><b><a href="qintvalidator.html#setRange">setRange</a></b> (<i>self</i>, int&#160;<i>bottom</i>, int&#160;<i>top</i>)</li><li><div class="fn" /><b><a href="qintvalidator.html#setTop">setTop</a></b> (<i>self</i>, int)</li><li><div class="fn" />int <b><a href="qintvalidator.html#top">top</a></b> (<i>self</i>)</li><li><div class="fn" />(QValidator.State, int) <b><a href="qintvalidator.html#validate">validate</a></b> (<i>self</i>, QString, int)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QIntValidator class provides a validator that ensures a string contains a valid integer within a specified range.</p>
<p>Example of use:</p>
<pre>
    QValidator *validator = new QIntValidator(100, 999, this);
    QLineEdit *edit = new QLineEdit(this);

    // the edit lineedit will only accept integers between 100 and 999
    edit-&gt;setValidator(validator);
</pre>
<p>Below we present some examples of validators. In practice they would normally be associated with a widget as in the example above.</p>
<pre>
    QString str;
    int pos = 0;
    QIntValidator v(100, 999, this);

    str = "1";
    v.validate(str, pos);     // returns Intermediate
    str = "12";
    v.validate(str, pos);     // returns Intermediate

    str = "123";
    v.validate(str, pos);     // returns Acceptable
    str = "678";
    v.validate(str, pos);     // returns Acceptable

    str = "1234";
    v.validate(str, pos);     // returns Invalid
    str = "-123";
    v.validate(str, pos);     // returns Invalid
    str = "abc";
    v.validate(str, pos);     // returns Invalid
    str = "12cm";
    v.validate(str, pos);     // returns Invalid
</pre>
<p>The minimum and maximum values are set in one call with <a href="qintvalidator.html#setRange">setRange</a>(), or individually with <a href="qintvalidator.html#bottom-prop">setBottom</a>() and <a href="qintvalidator.html#top-prop">setTop</a>().</p>
<p>See also <a href="qdoublevalidator.html">QDoubleValidator</a> and <a href="qregexpvalidator.html">QRegExpValidator</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QIntValidator" />QIntValidator.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a validator with a <i>parent</i> object that accepts all integers.</p>
<h3 class="fn"><a name="QIntValidator-2" />QIntValidator.__init__ (<i>self</i>, int&#160;<i>bottom</i>, int&#160;<i>top</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a validator with a <i>parent</i>, that accepts integers from <i>minimum</i> to <i>maximum</i> inclusive.</p>
<h3 class="fn"><a name="bottom" />int QIntValidator.bottom (<i>self</i>)</h3><h3 class="fn"><a name="setBottom" />QIntValidator.setBottom (<i>self</i>, int)</h3><h3 class="fn"><a name="setRange" />QIntValidator.setRange (<i>self</i>, int&#160;<i>bottom</i>, int&#160;<i>top</i>)</h3><p>Sets the range of the validator to only accept integers between <i>bottom</i> and <i>top</i> inclusive.</p>
<h3 class="fn"><a name="setTop" />QIntValidator.setTop (<i>self</i>, int)</h3><h3 class="fn"><a name="top" />int QIntValidator.top (<i>self</i>)</h3><h3 class="fn"><a name="validate" />(<a href="qvalidator.html#State-enum">QValidator.State</a>, int) QIntValidator.validate (<i>self</i>, <a href="qstring.html">QString</a>, int)</h3><p>Returns <a href="qvalidator.html#State-enum">Acceptable</a> if the <i>input</i> is an integer within the valid range, <a href="qvalidator.html#State-enum">Intermediate</a> if the <i>input</i> is an integer outside the valid range and <a href="qvalidator.html#State-enum">Invalid</a> if the <i>input</i> is not an integer.</p>
<p>Note: If the valid range consists of just positive integers (e.g. 32 to 100) and <i>input</i> is a negative integer then Invalid is returned.</p>
<pre>
    int pos = 0;

    s = "abc";
    v.validate(s, pos);    // returns Invalid

    s = "5";
    v.validate(s, pos);    // returns Intermediate

    s = "50";
    v.validate(s, pos);    // returns Acceptable
</pre>
<p>By default, the <i>pos</i> parameter is not used by this validator.</p>
<p>Reimplemented from <a href="qvalidator.html#validate">QValidator</a>.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt&#160;4.0.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.trolltech.com">Trolltech&#160;AS</a> 2006</td><td align="right" width="25%">Qt&#160;4.1.4</td></tr></table></div></address></body></html>