<tdalign="right"valign="center"><imgsrc="logo32.png"align="right"width="64"height="32"border="0"></td></tr></table><h1align=center>TQValidator Class Reference</h1>
<p>The TQValidator class provides validation of input text.
<p>Inherited by <ahref="qintvalidator.html">TQIntValidator</a>, <ahref="qdoublevalidator.html">TQDoubleValidator</a>, and <ahref="qregexpvalidator.html">TQRegExpValidator</a>.
<p><ahref="qvalidator-members.html">List of all member functions.</a>
The TQValidator class provides validation of input text.
<p>
<p> The class itself is abstract. Two subclasses, <ahref="qintvalidator.html">TQIntValidator</a> and
<ahref="qdoublevalidator.html">TQDoubleValidator</a>, provide basic numeric-range checking, and <ahref="qregexpvalidator.html">TQRegExpValidator</a> provides general checking using a custom <ahref="qregexp.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: <ahref="#validate">validate</a>() and
<ahref="#fixup">fixup</a>().
<p><ahref="#validate">validate</a>() must be implemented by every subclass. It returns
<ahref="#State-enum">Invalid</a>, <ahref="#State-enum">Intermediate</a> or <ahref="#State-enum">Acceptable</a> depending on whether
its argument is valid (for the subclass's definition of valid).
is <em>clearly</em> invalid. <ahref="#State-enum">Intermediate</a> is less obvious: the
concept of validity is slippery when the string is incomplete
(still being edited). TQValidator defines <ahref="#State-enum">Intermediate</a> as the
property of a string that is neither clearly invalid nor
acceptable as a final result. <ahref="#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 <ahref="#State-enum">Acceptable</a> string is <ahref="#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 <ahref="#State-enum">Acceptable</a>, the empty string and 1114 are <ahref="#State-enum">Intermediate</a> and asdf is <ahref="#State-enum">Invalid</a>.
<p><li> For an editable combobox that accepts URLs, any well-formed URL
is <ahref="#State-enum">Acceptable</a>, "http://www.trolltech.com/," is <ahref="#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 <ahref="#State-enum">Intermediate</a> (the user
might select and delete all of the text in preparation for entering
a new URL), and "http:///./" is <ahref="#State-enum">Invalid</a>.
<p><li> For a spin box that accepts lengths, "11cm" and "1in" are <ahref="#State-enum">Acceptable</a>, "11" and the empty string are <ahref="#State-enum">Intermediate</a> and
"http://www.trolltech.com" and "hour" are <ahref="#State-enum">Invalid</a>.
<p></ul>
<p><ahref="#fixup">fixup</a>() is provided for validators that can repair some user
errors. The default implementation does nothing. <ahref="qlineedit.html">TQLineEdit</a>, for
example, will call <ahref="#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 <ahref="#State-enum">Invalid</a> string <ahref="#State-enum">Acceptable</a>.
<p> TQValidator is typically used with TQLineEdit, <ahref="qspinbox.html">TQSpinBox</a> and
<ahref="qcombobox.html">TQComboBox</a>.
<p>See also <ahref="misc.html">Miscellaneous Classes</a>.
<p> This pure virtual function returns <ahref="#State-enum">Invalid</a> if <em>input</em> is
invalid according to this validator's rules, <ahref="#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 <ahref="#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 <ahref="qintvalidator.html#validate">TQIntValidator</a>, <ahref="qdoublevalidator.html#validate">TQDoubleValidator</a>, and <ahref="qregexpvalidator.html#validate">TQRegExpValidator</a>.
<!-- eof -->
<hr><p>
This file is part of the <ahref="index.html">TQt toolkit</a>.