Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 28b9e36e96ce34b2567ae5b47a27b2c5 > files > 1245

python-qt4-doc-4.10.3-3.mga4.noarch.rpm

<?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>QValidator 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="index.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">QValidator Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QValidator class provides validation of input text. <a href="#details">More...</a></p>

<p>Inherits <a href="qobject.html">QObject</a>.</p><p>Inherited by <a href="qdoublevalidator.html">QDoubleValidator</a>, <a href="qintvalidator.html">QIntValidator</a> and <a href="qregexpvalidator.html">QRegExpValidator</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qvalidator.html#State-enum">State</a></b> { Invalid, Intermediate, Acceptable }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qvalidator.html#QValidator">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />QString&#160;<i>input</i> <b><a href="qvalidator.html#fixup">fixup</a></b> (<i>self</i>, QString&#160;<i>input</i>)</li><li><div class="fn" /><b><a href="qvalidator.html#fixup-2">fixup</a></b> (<i>self</i>, QString)</li><li><div class="fn" />QLocale <b><a href="qvalidator.html#locale">locale</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qvalidator.html#setLocale">setLocale</a></b> (<i>self</i>, QLocale&#160;<i>locale</i>)</li><li><div class="fn" />(State, QString, int) <b><a href="qvalidator.html#validate">validate</a></b> (<i>self</i>, QString, int)</li><li><div class="fn" />(State, int) <b><a href="qvalidator.html#validate-2">validate</a></b> (<i>self</i>, QString, int)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QValidator class provides validation of input text.</p>
<p>The class itself is abstract. Two subclasses, <a href="qintvalidator.html">QIntValidator</a> and <a href="qdoublevalidator.html">QDoubleValidator</a>, provide basic
numeric-range checking, and <a href="qregexpvalidator.html">QRegExpValidator</a> provides general
checking using a custom regular expression.</p>
<p>If the built-in validators aren't sufficient, you can subclass
QValidator. The class has two virtual functions: <a href="qvalidator.html#validate">validate</a>() and <a href="qvalidator.html#fixup">fixup</a>().</p>
<p><a href="qvalidator.html#validate">validate</a>() must be
implemented by every subclass. It returns <a href="qvalidator.html#State-enum">Invalid</a>, <a href="qvalidator.html#State-enum">Intermediate</a> or <a href="qvalidator.html#State-enum">Acceptable</a> depending on whether
its argument is valid (for the subclass's definition of valid).</p>
<p>These three states require some explanation. An <a href="qvalidator.html#State-enum">Invalid</a> string is <i>clearly</i>
invalid. <a href="qvalidator.html#State-enum">Intermediate</a> is
less obvious: the concept of validity is difficult to apply when
the string is incomplete (still being edited). QValidator defines
<a href="qvalidator.html#State-enum">Intermediate</a> as the
property of a string that is neither clearly invalid nor acceptable
as a final result. <a href="qvalidator.html#State-enum">Acceptable</a> means that the string
is acceptable as a final result. One might say that any string that
is a plausible intermediate state during entry of an <a href="qvalidator.html#State-enum">Acceptable</a> string is <a href="qvalidator.html#State-enum">Intermediate</a>.</p>
<p>Here are some examples:</p>
<ul>
<li>For a line edit that accepts integers from 10 to 1000
inclusive, 42 and 123 are <a href="qvalidator.html#State-enum">Acceptable</a>, the empty string and 5
are <a href="qvalidator.html#State-enum">Intermediate</a>, and
"asdf" and 1114 is <a href="qvalidator.html#State-enum">Invalid</a>.</li>
<li>For an editable combobox that accepts URLs, any well-formed URL
is <a href="qvalidator.html#State-enum">Acceptable</a>,
"http://example.com/," is <a href="qvalidator.html#State-enum">Intermediate</a> (it might be a cut
and paste action that accidentally took in a comma at the end), the
empty string is <a href="qvalidator.html#State-enum">Intermediate</a> (the user might
select and delete all of the text in preparation for entering a new
URL) and "http:///./" is <a href="qvalidator.html#State-enum">Invalid</a>.</li>
<li>For a spin box that accepts lengths, "11cm" and "1in" are
<a href="qvalidator.html#State-enum">Acceptable</a>, "11" and the
empty string are <a href="qvalidator.html#State-enum">Intermediate</a>, and
"http://example.com" and "hour" are <a href="qvalidator.html#State-enum">Invalid</a>.</li>
</ul>
<p><a href="qvalidator.html#fixup">fixup</a>() is provided for
validators that can repair some user errors. The default
implementation does nothing. <a href="qlineedit.html">QLineEdit</a>, for example, will call <a href="qvalidator.html#fixup">fixup</a>() if the user presses Enter (or
Return) and the content is not currently valid. This allows the
<a href="qvalidator.html#fixup">fixup</a>() function the
opportunity of performing some magic to make an <a href="qvalidator.html#State-enum">Invalid</a> string <a href="qvalidator.html#State-enum">Acceptable</a>.</p>
<p>A validator has a locale, set with <a href="qvalidator.html#setLocale">setLocale</a>(). It is typically used
to parse localized data. For example, <a href="qintvalidator.html">QIntValidator</a> and <a href="qdoublevalidator.html">QDoubleValidator</a> use it to parse
localized representations of integers and doubles.</p>
<p>QValidator is typically used with <a href="qlineedit.html">QLineEdit</a>, <a href="qspinbox.html">QSpinBox</a> and <a href="qcombobox.html">QComboBox</a>.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="State-enum" />QValidator.State</h3><p>This enum type defines the states in which a validated string
can exist.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QValidator.Invalid</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">The string is <i>clearly</i> invalid.</td>
</tr>
<tr>
<td class="topAlign"><tt>QValidator.Intermediate</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">The string is a plausible intermediate
value.</td>
</tr>
<tr>
<td class="topAlign"><tt>QValidator.Acceptable</tt></td>
<td class="topAlign"><tt>2</tt></td>
<td class="topAlign">The string is acceptable as a final result;
i.e. it is valid.</td>
</tr>
</table>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QValidator" />QValidator.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Sets up the validator. The <i>parent</i> parameter is passed on
to the <a href="qobject.html">QObject</a> constructor.</p>


<h3 class="fn"><a name="fixup" />QString&#160;<i>input</i> QValidator.fixup (<i>self</i>, QString&#160;<i>input</i>)</h3><p>This function attempts to change <i>input</i> to be valid
according to this validator's rules. It need not result in a valid
string: callers of this function must re-test afterwards; the
default does nothing.</p>
<p>Reimplementations of this function can change <i>input</i> even
if they do not produce a valid string. For example, an ISBN
validator might want to delete every character except digits and
"-", even if the result is still not a valid ISBN; a surname
validator might want to remove whitespace from the start and end of
the string, even if the resulting string is not in the list of
accepted surnames.</p>


<h3 class="fn"><a name="fixup-2" />QValidator.fixup (<i>self</i>, QString)</h3><h3 class="fn"><a name="locale" /><a href="qlocale.html">QLocale</a> QValidator.locale (<i>self</i>)</h3><p>Returns the locale for the validator. The locale is by default
initialized to the same as QLocale().</p>
<p><b>See also</b> <a href="qvalidator.html#setLocale">setLocale</a>() and <a href="qlocale.html#QLocale">QLocale.QLocale</a>().</p>


<h3 class="fn"><a name="setLocale" />QValidator.setLocale (<i>self</i>, <a href="qlocale.html">QLocale</a>&#160;<i>locale</i>)</h3><p>Sets the <i>locale</i> that will be used for the validator.
Unless setLocale has been called, the validator will use the
default locale set with <a href="qlocale.html#setDefault">QLocale.setDefault</a>(). If a default
locale has not been set, it is the operating system's locale.</p>
<p><b>See also</b> <a href="qvalidator.html#locale">locale</a>()
and <a href="qlocale.html#setDefault">QLocale.setDefault</a>().</p>


<h3 class="fn"><a name="validate" />(<a href="qvalidator.html#State-enum">State</a>, QString, int) QValidator.validate (<i>self</i>, QString, int)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This virtual function returns <a href="qvalidator.html#State-enum">Invalid</a> if <i>input</i> is invalid
according to this validator's rules, <a href="qvalidator.html#State-enum">Intermediate</a> if it is likely that
a little more editing will make the input acceptable (e.g. the user
types "4" into a widget which accepts integers between 10 and 99),
and <a href="qvalidator.html#State-enum">Acceptable</a> if the
input is valid.</p>
<p>The function can change both <i>input</i> and <i>pos</i> (the
cursor position) if required.</p>
<h3 class="fn"><a name="validate-2" />(<a href="qvalidator.html#State-enum">State</a>, int) QValidator.validate (<i>self</i>, QString, int)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.10.3 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.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.5</td></tr></table></div></address></body></html>