Eneboo - Documentación para desarrolladores
Tipos públicos | Métodos públicos
Referencia de la Clase QValidator

The QValidator class provides validation of input text. Más...

#include <qvalidator.h>

Diagrama de herencias de QValidator
QObject QObject Qt Qt Qt Qt AsciiValidator QDoubleValidator QDoubleValidator QIntValidator QIntValidator QRegExpValidator QRegExpValidator VDateValidator

Lista de todos los miembros.

Tipos públicos

enum  State {
  Invalid, Intermediate, Valid = Intermediate, Acceptable,
  Invalid, Intermediate, Valid = Intermediate, Acceptable
}
enum  State {
  Invalid, Intermediate, Valid = Intermediate, Acceptable,
  Invalid, Intermediate, Valid = Intermediate, Acceptable
}

Métodos públicos

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

Descripción detallada

The QValidator class provides validation of input text.

The class itself is abstract. Two subclasses, QIntValidator and QDoubleValidator, provide basic numeric-range checking, and QRegExpValidator provides general checking using a custom regular expression.

If the built-in validators aren't sufficient, you can subclass QValidator. The class has two virtual functions: validate() and fixup().

validate() must be implemented by every subclass. It returns Invalid, Intermediate or Acceptable depending on whether its argument is valid (for the subclass's definition of valid).

These three states require some explanation. An Invalid string is clearly invalid. Intermediate is less obvious: the concept of validity is slippery when the string is incomplete (still being edited). QValidator defines Intermediate as the property of a string that is neither clearly invalid nor acceptable as a final result. Acceptable 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 Acceptable string is Intermediate.

Here are some examples:

For a line edit that accepts integers from 0 to 999 inclusive, 42 and 123 are Acceptable, the empty string and 1114 are Intermediate and asdf is Invalid.

For an editable combobox that accepts URLs, any well-formed URL is Acceptable, "http://www.trolltech.com/," is Intermediate (it might be a cut and paste operation that accidentally took in a comma at the end), the empty string is Intermediate (the user might select and delete all of the text in preparation for entering a new URL), and "http:///./" is Invalid.

For a spin box that accepts lengths, "11cm" and "1in" are Acceptable, "11" and the empty string are Intermediate and "http://www.trolltech.com" and "hour" are Invalid.

fixup() is provided for validators that can repair some user errors. The default implementation does nothing. QLineEdit, for example, will call fixup() 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 Invalid string Acceptable.

QValidator is typically used with QLineEdit, QSpinBox and QComboBox.


Documentación de las enumeraciones miembro de la clase

This enum type defines the states in which a validated string can exist.

Invalid the string is clearly invalid.

Intermediate the string is a plausible intermediate value during editing.

Acceptable the string is acceptable as a final result, i.e. it is valid.

Valores de enumeraciones:
Invalid 
Intermediate 
Valid 
Acceptable 
Invalid 
Intermediate 
Valid 
Acceptable 
Valores de enumeraciones:
Invalid 
Intermediate 
Valid 
Acceptable 
Invalid 
Intermediate 
Valid 
Acceptable 

Documentación del constructor y destructor

QValidator::QValidator ( QObject parent,
const char *  name = 0 
)

Sets up the validator. The parent and name parameters are passed on to the QObject constructor.

QValidator::~QValidator ( )

Destroys the validator, freeing any storage and other resources used.

QValidator::QValidator ( QObject parent,
const char *  name = 0 
)
QValidator::~QValidator ( )

Documentación de las funciones miembro

void QValidator::fixup ( QString input) const [virtual]

This function attempts to change input 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.

Reimplementations of this function can change input 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.

Reimplementado en VDateValidator.

virtual void QValidator::fixup ( QString ) const [virtual]

Reimplementado en VDateValidator.

virtual State QValidator::validate ( QString ,
int  
) const [pure virtual]
QValidator::State QValidator::validate ( QString input,
int pos 
) const [pure virtual]

This pure virtual function returns Invalid if input is invalid according to this validator's rules, Intermediate 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 Acceptable if the input is valid.

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

Implementado en VDateValidator, FLDoubleValidator, FLIntValidator, FLUIntValidator, QIntValidator, QDoubleValidator, QRegExpValidator, QColIntValidator, QSpinBoxValidator, QIntValidator, QDoubleValidator, QRegExpValidator y AsciiValidator.


La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'