QValidator(3qt)

NAME
QValidator - Validation of input text

SYNOPSIS

#include <qvalidator.h>

Inherits QObject.

Inherited by QDoubleValidator and QIntValidator.

  Public Members
QValidator ( QWidget * parent, const char * name = 0 )
~QValidator ()
virtual State validate ( QString &, int & )
virtual void fixup ( QString & )

DESCRIPTION
The QValidator class provides validation of input text.

The class itself is abstract; two subclasses provide rudimentary numeric range checking.

The class includes two virtual functions, validate() and fixup().

validate() is pure virtual, so it must be implemented by every subclass. It returns Invalid, Valid or Acceptable depending on whether its argument is valid (for the class' definition of valid).

fixup() is provided for validators that can repair some or all user errors. The default does nothing. QLineEdit, for example, will call fixup() if the user presses Return and the content is not currently valid, in case fixup() can do magic.

QValidator is generally used with QLineEdit, QSpinBox and QComboBox.

MEMBER FUNCTION DOCUMENTATION

QValidator::QValidator ( QWidget * parent, const char * name = 0 )
Sets up the internal data structures used by the validator. At the moment there aren't any.

QValidator::~QValidator ()
Deletes the validator and frees any storage and other resources used.

void QValidator::fixup ( QString & input ) [virtual]
Attempts to change to be valid according to this validator's rules. Need not result in a valid string - callers of this function must re-test afterwards. The default does nothing.

Reimplementation notes:

Note that input may not be the only QString object referencing this string, so it's almost always necessary to detach() the string at the start of the code:

    input.detach();

You can change input even if you aren't able to 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, and a last-name validator might want to remove white space from the start and end of the string, even if the resulting string is not in the list of known last names.

QValidator::State QValidator::validate( QString & input, int & pos ) [virtual]
This pure virtual function returns Invalid if input is invalid according to this validator's rules, Valid 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 10-99) and Acceptable if the input is completely acceptable.

The function can change input and pos (the cursor position) if it wants to.

Reimplemented in QIntValidator and QDoubleValidator.

SEE ALSO
http://www.troll.no/qt/qvalidator.html

COPYRIGHT
Copyright 1992-1997 Troll Tech AS. See the LICENSE file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.