|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QValidator
public abstract class QValidator
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 difficult to apply 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:
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.
A validator has a locale, set with setLocale. It is typically used to parse localized data. For example, QIntValidator and QDoubleValidator use it to parse localized representations of integers and doubles.
QValidator is typically used with QLineEdit, QSpinBox and QComboBox.
Nested Class Summary | |
---|---|
static class |
QValidator.QValidationData
|
static class |
QValidator.State
This enum type defines the states in which a validated string can exist. |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Constructor Summary | |
---|---|
QValidator(QObject parent)
Sets up the validator. |
Method Summary | |
---|---|
java.lang.String |
fixup(java.lang.String arg__1)
This function attempts to change arg__1 to be valid according to this validator's rules. |
static QValidator |
fromNativePointer(QNativePointer nativePointer)
This function returns the QValidator instance pointed to by nativePointer |
QLocale |
locale()
Returns the locale for the validator. |
void |
setLocale(QLocale locale)
Sets the locale that will be used for the validator. |
abstract QValidator.State |
validate(QValidator.QValidationData arg__1)
Equivalent to validate(arg__1, ). |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
disconnect, disconnect, signalSender |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QValidator(QObject parent)
Sets up the validator. The parent parameter is passed on to the QObject constructor.
Method Detail |
---|
public final QLocale locale()
Returns the locale for the validator. The locale is by default initialized to the same as QLocale().
public final void setLocale(QLocale locale)
Sets the locale that will be used for the validator. Unless setLocale 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.
public java.lang.String fixup(java.lang.String arg__1)
This function attempts to change arg__1 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 arg__1 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.
public abstract QValidator.State validate(QValidator.QValidationData arg__1)
Equivalent to validate(arg__1, ).
public static QValidator fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |