Qt Jambi Home

com.trolltech.qt.gui
Class QIntValidator

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QValidator
                  extended by com.trolltech.qt.gui.QIntValidator
All Implemented Interfaces:
QtJambiInterface

public class QIntValidator
extends QValidator

The QIntValidator class provides a validator that ensures a string contains a valid integer within a specified range.

Example of use:

    QValidator *validator = new QIntValidator(100, 999, this);
    QLineEdit *edit = new QLineEdit(this);

    // the edit lineedit will only accept integers between 100 and 999
    edit->setValidator(validator);

Below we present some examples of validators. In practice they would normally be associated with a widget as in the example above.

    QString str;
    int pos = 0;
    QIntValidator v(100, 999, this);

    str = "1";
    v.validate(str, pos);     // returns Intermediate
    str = "12";
    v.validate(str, pos);     // returns Intermediate

    str = "123";
    v.validate(str, pos);     // returns Acceptable
    str = "678";
    v.validate(str, pos);     // returns Acceptable

    str = "1234";
    v.validate(str, pos);     // returns Invalid
    str = "-123";
    v.validate(str, pos);     // returns Invalid
    str = "abc";
    v.validate(str, pos);     // returns Invalid
    str = "12cm";
    v.validate(str, pos);     // returns Invalid

The minimum and maximum values are set in one call with setRange, or individually with setBottom and setTop.

QIntValidator uses its locale to interpret the number. For example, in Arabic locales, QIntValidator will accept Arabic digits. In addition, QIntValidator is always guaranteed to accept a number formatted according to the "C" locale.

See Also:
QDoubleValidator, QRegExpValidator, Line Edits Example

Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QValidator
QValidator.QValidationData, QValidator.State
 
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
QIntValidator(int bottom, int top, QObject parent)
          Constructs a validator with a parent, that accepts integers from bottom to top inclusive.
QIntValidator(QObject parent)
          Constructs a validator with a parent object that accepts all integers.
 
Method Summary
 int bottom()
          Returns the validator's lowest acceptable value.
static QIntValidator fromNativePointer(QNativePointer nativePointer)
          This function returns the QIntValidator instance pointed to by nativePointer
 void setBottom(int arg__1)
          Sets the validator's lowest acceptable value to arg__1.
 void setRange(int bottom, int top)
          Sets the range of the validator to only accept integers between bottom and top inclusive.
 void setTop(int arg__1)
          Sets the validator's highest acceptable value to arg__1.
 int top()
          Returns the validator's highest acceptable value.
 QValidator.State validate(QValidator.QValidationData arg__1)
          Equivalent to validate(arg__1, ).
 
Methods inherited from class com.trolltech.qt.gui.QValidator
fixup, locale, setLocale
 
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

QIntValidator

public QIntValidator(int bottom,
                     int top,
                     QObject parent)

Constructs a validator with a parent, that accepts integers from bottom to top inclusive.


QIntValidator

public QIntValidator(QObject parent)

Constructs a validator with a parent object that accepts all integers.

Method Detail

bottom

public final int bottom()

Returns the validator's lowest acceptable value.

See Also:
setBottom, setRange

setBottom

public final void setBottom(int arg__1)

Sets the validator's lowest acceptable value to arg__1.

See Also:
bottom, setRange

setTop

public final void setTop(int arg__1)

Sets the validator's highest acceptable value to arg__1.

See Also:
top, setRange

top

public final int top()

Returns the validator's highest acceptable value.

See Also:
setTop, setRange

setRange

public void setRange(int bottom,
                     int top)

Sets the range of the validator to only accept integers between bottom and top inclusive.


validate

public QValidator.State validate(QValidator.QValidationData arg__1)

Equivalent to validate(arg__1, ).

Specified by:
validate in class QValidator

fromNativePointer

public static QIntValidator fromNativePointer(QNativePointer nativePointer)
This function returns the QIntValidator instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

Qt Jambi Home