You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
154 lines
8.6 KiB
154 lines
8.6 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qvalidator.cpp:44 -->
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>TQValidator Class</title>
|
|
<style type="text/css"><!--
|
|
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 Classes</font></a>
|
|
| <a href="mainclasses.html">
|
|
<font color="#004faf">Main Classes</font></a>
|
|
| <a href="annotated.html">
|
|
<font color="#004faf">Annotated</font></a>
|
|
| <a href="groups.html">
|
|
<font color="#004faf">Grouped 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>TQValidator Class Reference</h1>
|
|
|
|
<p>The TQValidator class provides validation of input text.
|
|
<a href="#details">More...</a>
|
|
<p><tt>#include <<a href="qvalidator-h.html">ntqvalidator.h</a>></tt>
|
|
<p>Inherits <a href="ntqobject.html">TQObject</a>.
|
|
<p>Inherited by <a href="qintvalidator.html">TQIntValidator</a>, <a href="qdoublevalidator.html">TQDoubleValidator</a>, and <a href="qregexpvalidator.html">TQRegExpValidator</a>.
|
|
<p><a href="qvalidator-members.html">List of all member functions.</a>
|
|
<h2>Public Members</h2>
|
|
<ul>
|
|
<li class=fn><a href="#TQValidator"><b>TQValidator</b></a> ( TQObject * parent, const char * name = 0 )</li>
|
|
<li class=fn><a href="#~TQValidator"><b>~TQValidator</b></a> ()</li>
|
|
<li class=fn>enum <a href="#State-enum"><b>State</b></a> { Invalid, Intermediate, Valid = Intermediate, Acceptable }</li>
|
|
<li class=fn>virtual State <a href="#validate"><b>validate</b></a> ( TQString & input, int & pos ) const = 0</li>
|
|
<li class=fn>virtual void <a href="#fixup"><b>fixup</b></a> ( TQString & input ) const</li>
|
|
</ul>
|
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
|
|
|
|
|
The TQValidator class provides validation of input text.
|
|
<p>
|
|
|
|
<p> The class itself is abstract. Two subclasses, <a href="qintvalidator.html">TQIntValidator</a> and
|
|
<a href="qdoublevalidator.html">TQDoubleValidator</a>, provide basic numeric-range checking, and <a href="qregexpvalidator.html">TQRegExpValidator</a> provides general checking using a custom <a href="ntqregexp.html#regular-expression">regular expression</a>.
|
|
<p> If the built-in validators aren't sufficient, you can subclass
|
|
TQValidator. 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). TQValidator 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 123 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 operation that accidentally took in a
|
|
comma at the end), the empty string is <a href="#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="#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="ntqlineedit.html">TQLineEdit</a>, for
|
|
example, will call <a href="#fixup">fixup</a>() if the user presses Enter (or Return)
|
|
and the content is not currently valid. This allows the fixup()
|
|
function the opportunity of performing some magic to make an <a href="#State-enum">Invalid</a> string <a href="#State-enum">Acceptable</a>.
|
|
<p> TQValidator is typically used with TQLineEdit, <a href="ntqspinbox.html">TQSpinBox</a> and
|
|
<a href="ntqcombobox.html">TQComboBox</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>TQValidator::State</h3>
|
|
|
|
<p> This enum type defines the states in which a validated string can
|
|
exist.
|
|
<ul>
|
|
<li><tt>TQValidator::Invalid</tt> - the string is <em>clearly</em> invalid.
|
|
<li><tt>TQValidator::Intermediate</tt> - the string is a plausible intermediate value
|
|
during editing.
|
|
<li><tt>TQValidator::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="TQValidator"></a>TQValidator::TQValidator ( <a href="ntqobject.html">TQObject</a> * parent, const char * name = 0 )
|
|
</h3>
|
|
Sets up the validator. The <em>parent</em> and <em>name</em> parameters are
|
|
passed on to the <a href="ntqobject.html">TQObject</a> constructor.
|
|
|
|
<h3 class=fn><a name="~TQValidator"></a>TQValidator::~TQValidator ()
|
|
</h3>
|
|
Destroys the validator, freeing any storage and other resources
|
|
used.
|
|
|
|
<h3 class=fn>void <a name="fixup"></a>TQValidator::fixup ( <a href="ntqstring.html">TQString</a> & 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 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.
|
|
|
|
<h3 class=fn><a href="ntqvalidator.html#State-enum">State</a> <a name="validate"></a>TQValidator::validate ( <a href="ntqstring.html">TQString</a> & input, int & 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">TQIntValidator</a>, <a href="qdoublevalidator.html#validate">TQDoubleValidator</a>, and <a href="qregexpvalidator.html#validate">TQRegExpValidator</a>.
|
|
<!-- eof -->
|
|
<hr><p>
|
|
This file is part of the <a href="index.html">TQt toolkit</a>.
|
|
Copyright © 1995-2007
|
|
<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 © 2007
|
|
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
|
<td align=right><div align=right>TQt 3.3.8</div>
|
|
</table></div></address></body>
|
|
</html>
|