<class name="QValidator" doc="/** <p>The <a href="QValidator.html#QValidator(com.trolltech.qt.core.QObject)"><tt>QValidator</tt></a> class provides validation of input text.</p> <p>The class itself is abstract. Two subclasses, <a href="QIntValidator.html"><tt>QIntValidator</tt></a> and <a href="QDoubleValidator.html"><tt>QDoubleValidator</tt></a>, provide basic numeric-range checking, and <a href="QRegExpValidator.html"><tt>QRegExpValidator</tt></a> provides general checking using a custom regular expression.</p> <p>If the built-in validators aren't sufficient, you can subclass <a href="QValidator.html#QValidator(com.trolltech.qt.core.QObject)"><tt>QValidator</tt></a>. The class has two virtual functions: <a href="QValidator.html#validate(com.trolltech.qt.gui.QValidator.QValidationData)"><tt>validate</tt></a> and <a href="QValidator.html#fixup(java.lang.String)"><tt>fixup</tt></a>.</p> <p><a href="QValidator.html#validate(com.trolltech.qt.gui.QValidator.QValidationData)"><tt>validate</tt></a> must be implemented by every subclass. It returns <a href="QValidator.html#State-enum">Invalid</tt></a>, <a href="QValidator.html#State-enum">Intermediate</tt></a> or <a href="QValidator.html#State-enum">Acceptable</tt></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</tt></a> string is <i>clearly</i> invalid. <a href="QValidator.html#State-enum">Intermediate</tt></a> is less obvious: the concept of validity is difficult to apply when the string is incomplete (still being edited). <a href="QValidator.html#QValidator(com.trolltech.qt.core.QObject)"><tt>QValidator</tt></a> defines <a href="QValidator.html#State-enum">Intermediate</tt></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</tt></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</tt></a> string is <a href="QValidator.html#State-enum">Intermediate</tt></a>.</p> <p>Here are some examples:</p> <ul> <li>For a line edit that accepts integers from 10 to 999 inclusive, 42 and 123 are <a href="QValidator.html#State-enum">Acceptable</tt></a>, the empty string and 5 are <a href="QValidator.html#State-enum">Intermediate</tt></a>, and &quot;asdf&quot; and 1114 is <a href="QValidator.html#State-enum">Invalid</tt></a>.</li> <li>For an editable combobox that accepts URLs, any well-formed URL is <a href="QValidator.html#State-enum">Acceptable</tt></a>, &quot;http://www.trolltech.com/,&quot; is <a href="QValidator.html#State-enum">Intermediate</tt></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</tt></a> (the user might select and delete all of the text in preparation for entering a new URL) and &quot;http:///./&quot; is <a href="QValidator.html#State-enum">Invalid</tt></a>.</li> <li>For a spin box that accepts lengths, &quot;11cm&quot; and &quot;1in&quot; are <a href="QValidator.html#State-enum">Acceptable</tt></a>, &quot;11&quot; and the empty string are <a href="QValidator.html#State-enum">Intermediate</tt></a>, and &quot;http://www.trolltech.com&quot; and &quot;hour&quot; are <a href="QValidator.html#State-enum">Invalid</tt></a>.</li> </ul> <p><a href="QValidator.html#fixup(java.lang.String)"><tt>fixup</tt></a> is provided for validators that can repair some user errors. The default implementation does nothing. <a href="QLineEdit.html"><tt>QLineEdit</tt></a>, for example, will call <a href="QValidator.html#fixup(java.lang.String)"><tt>fixup</tt></a> if the user presses Enter (or Return) and the content is not currently valid. This allows the <a href="QValidator.html#fixup(java.lang.String)"><tt>fixup</tt></a> function the opportunity of performing some magic to make an <a href="QValidator.html#State-enum">Invalid</tt></a> string <a href="QValidator.html#State-enum">Acceptable</tt></a>.</p> <p>A validator has a locale, set with <a href="QValidator.html#setLocale(com.trolltech.qt.core.QLocale)"><tt>setLocale</tt></a>. It is typically used to parse localized data. For example, <a href="QIntValidator.html"><tt>QIntValidator</tt></a> and <a href="QDoubleValidator.html"><tt>QDoubleValidator</tt></a> use it to parse localized representations of integers and doubles.</p> <p><a href="QValidator.html#QValidator(com.trolltech.qt.core.QObject)"><tt>QValidator</tt></a> is typically used with <a href="QLineEdit.html"><tt>QLineEdit</tt></a>, <a href="QSpinBox.html"><tt>QSpinBox</tt></a> and <a href="QComboBox.html"><tt>QComboBox</tt></a>.</p> @see <a href="QIntValidator.html"><tt>QIntValidator</tt></a> @see <a href="QDoubleValidator.html"><tt>QDoubleValidator</tt></a> @see <a href="QRegExpValidator.html"><tt>QRegExpValidator</tt></a> @see <a href="%2E%2E/qtjambi-lineedits.html">Line Edits Example</tt></a> */"> <method name="public QValidator(com.trolltech.qt.core.QObject parent)" doc="/** <p>Sets up the validator. The <tt>parent</tt> parameter is passed on to the <a href="%2E%2E/core/%2E%2E/core/QObject.html#QObject(com.trolltech.qt.core.QObject)"><tt>QObject</tt></a> constructor.</p> */"/> <method name="public final com.trolltech.qt.core.QLocale locale()" doc="/** <p>Returns the locale for the validator. The locale is by default initialized to the same as QLocale().</p> @see <a href="QValidator.html#setLocale(com.trolltech.qt.core.QLocale)"><tt>setLocale</tt></a> @see <tt>QLocale::QLocale</tt> */"/> <method name="public final void setLocale(com.trolltech.qt.core.QLocale locale)" doc="/** <p>Sets the <tt>locale</tt> that will be used for the validator. Unless <a href="QValidator.html#setLocale(com.trolltech.qt.core.QLocale)"><tt>setLocale</tt></a> has been called, the validator will use the default locale set with QLocale::setDefault(). If a default locale has not been set, it is the operating system's locale.</p> @see <a href="QValidator.html#locale()"><tt>locale</tt></a> @see <tt>QLocale::setDefault</tt> */"/> <method name="public java.lang.String fixup(java.lang.String arg__1)" doc="/** <p>This function attempts to change <tt>arg__1</tt> 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 <tt>arg__1</tt> even if they do not produce a valid string. For example, an ISBN validator might want to delete every character except digits and &quot;-&quot;, 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> */"/> <method name="public abstract com.trolltech.qt.gui.QValidator.State validate(com.trolltech.qt.gui.QValidator.QValidationData arg__1)" doc="/** <p>Equivalent to <a href="QValidator.html#validate(com.trolltech.qt.gui.QValidator.QValidationData)">validate</tt></a>(<tt>arg__1</tt>, ). */"/> <enum name="State" doc="/** <p>This enum type defines the states in which a validated string can exist.</p> */"> <enum-value name="Invalid" doc="/** <p>The string is <i>clearly</i> invalid.</p> */"/> <enum-value name="Intermediate" doc="/** <p>The string is a plausible intermediate value during editing.</p> */"/> <enum-value name="Acceptable" doc="/** <p>The string is acceptable as a final result; i.e&#x2e; it is valid.</p> */"/> </enum> </class>