Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 112b0974ad288f6cd55bf971ee6026a9 > files > 2002

libqt3-devel-3.0.2-2mdk.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/src/widgets/qvalidator.cpp:46 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QValidator Class</title>
<style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QValidator Class Reference</h1>

<p>The QValidator class provides validation of input text.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qvalidator-h.html">qvalidator.h</a>&gt;</tt>
<p>Inherits <a href="qobject.html">QObject</a>.
<p>Inherited by <a href="qintvalidator.html">QIntValidator</a>, <a href="qdoublevalidator.html">QDoubleValidator</a> and <a href="qregexpvalidator.html">QRegExpValidator</a>.
<p><a href="qvalidator-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class=fn><a href="#QValidator"><b>QValidator</b></a> ( QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</div></li>
<li><div class=fn><a href="#~QValidator"><b>~QValidator</b></a> ()</div></li>
<li><div class=fn>enum <a href="#State-enum"><b>State</b></a> { Invalid, Intermediate, Valid = Intermediate, Acceptable }</div></li>
<li><div class=fn>virtual State <a href="#validate"><b>validate</b></a> ( QString&nbsp;&amp;&nbsp;input, int&nbsp;&amp;&nbsp;pos ) const = 0</div></li>
<li><div class=fn>virtual void <a href="#fixup"><b>fixup</b></a> ( QString&nbsp;&amp;&nbsp;input ) const</div></li>
</ul>
<hr><a name="details"></a><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
<a href="qregexp.html#regular-expression">regular expression</a>.
<p> If the built-in validators aren't sufficient, you can subclass
QValidator. The class has two virtual functions: <a href="#validate">validate</a>()
and <a href="#fixup">fixup</a>().
<p> <a href="#validate">validate</a>() must be implemented by every subclass.  It returns <a href="#State-enum">Invalid</a>, <a href="#State-enum">Intermediate</a> or <a href="#State-enum">Acceptable</a> depending on whether its
argument is valid (for the subclass's definition of valid).
<p> These three states require some explanation.  An <a href="#State-enum">Invalid</a> string is
<em>clearly</em> invalid.  <a href="#State-enum">Intermediate</a> is less obvious - the concept
of validity is slippery when the string is incomplete (still being
edited).  QValidator defines <a href="#State-enum">Intermediate</a> as the property of a
string that is neither clearly invalid nor acceptable as a final
result.  <a href="#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="#State-enum">Acceptable</a> string is <a href="#State-enum">Intermediate</a>.
<p> Here are some examples:
<p> <ul>
<p> <li> For a line edit that accepts integers from 0 to 999 inclusive,
42 and 666 are <a href="#State-enum">Acceptable</a>, the empty string and 1114 are <a href="#State-enum">Intermediate</a> and asdf is <a href="#State-enum">Invalid</a>.
<p> <li> For an editable combobox that accepts URLs, any well-formed URL
is <a href="#State-enum">Acceptable</a>, "http://www.trolltech.com/," is <a href="#State-enum">Intermediate</a> (it might
be a cut-and-paste that accidentally took in a comma at the
end), the empty string is valid (the user might select and delete
all of the text in preparation of entering a new URL) and
"http:///./" is <a href="#State-enum">Invalid</a>.
<p> <li> For a spin box that accepts lengths, "11cm" and "1in" are <a href="#State-enum">Acceptable</a>, "11" and the empty string are <a href="#State-enum">Intermediate</a> and
"http://www.trolltech.com" and "hour" are <a href="#State-enum">Invalid</a>.
<p> </ul>
<p> <a href="#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="#fixup">fixup</a>() if the user presses Enter and the
content is not currently valid, in case fixup() can do magic.  This
allows some <a href="#State-enum">Invalid</a> strings to be made <a href="#State-enum">Acceptable</a>, too.
<p> QValidator is typically used with QLineEdit, <a href="qspinbox.html">QSpinBox</a> and <a href="qcombobox.html">QComboBox</a>.
<p>See also <a href="misc.html">Miscellaneous Classes</a>.

<hr><h2>Member Type Documentation</h2>
<h3 class=fn><a name="State-enum"></a>QValidator::State</h3> 
<p> This enum type defines the states in which a validated string can
exist.  There are currently three states:
<ul>
<li><tt>QValidator::Invalid</tt> - the string is <em>clearly</em> invalid.
<li><tt>QValidator::Intermediate</tt> - the string is a plausible intermediate value
during editing.
<li><tt>QValidator::Acceptable</tt> - the string is acceptable as a final result, i.e.
it is valid.
</ul>
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QValidator"></a>QValidator::QValidator ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Sets up the internal data structures used by the validator.  At
the moment there aren't any. The <em>parent</em> and <em>name</em> parameters
are passed to the <a href="qobject.html">QObject</a> constructor.

<h3 class=fn><a name="~QValidator"></a>QValidator::~QValidator ()
</h3>
Destroys the validator, freeing any storage and other resources
used.

<h3 class=fn>void <a name="fixup"></a>QValidator::fixup ( <a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;input ) const<tt> [virtual]</tt>
</h3>

<p> This function attempts to change <em>input</em> 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> Reimplementations of this function can change <em>input</em> 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 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.

<h3 class=fn><a href="qvalidator.html#State-enum">State</a> <a name="validate"></a>QValidator::validate ( <a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;input, int&nbsp;&amp;&nbsp;pos ) const<tt> [pure virtual]</tt>
</h3>

<p> This pure virtual function returns <a href="#State-enum">Invalid</a> if <em>input</em> is invalid
according to this validator's rules, <a href="#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="#State-enum">Acceptable</a> if the input is valid.
<p> The function can change <em>input</em> and <em>pos</em> (the cursor position) if
it wants to.

<p>Reimplemented in <a href="qintvalidator.html#validate">QIntValidator</a>, <a href="qdoublevalidator.html#validate">QDoubleValidator</a> and <a href="qregexpvalidator.html#validate">QRegExpValidator</a>.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2001
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2001 
<a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt version 3.0.2</div>
</table></div></address></body>
</html>