[][src]Struct qt_gui::QIntValidator

#[repr(C)]pub struct QIntValidator { /* fields omitted */ }

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

C++ class: QIntValidator.

C++ documentation:

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, 900, this);

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

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

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

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

Notice that the value 999 returns Intermediate. Values consisting of a number of digits equal to or less than the max value are considered intermediate. This is intended because the digit that prevents a number from being in range is not necessarily the last digit typed. This also means that an intermediate number can have leading zeros.

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.

Note: The QLocale::NumberOptions set on the locale() also affect the way the number is interpreted. For example, since QLocale::RejectGroupSeparator is not set by default, the validator will accept group separators. It is thus recommended to use QLocale::toInt() to obtain the numeric value.

Methods

impl QIntValidator[src]

pub fn bottom_changed(&self) -> Signal<(c_int,)>[src]

This property holds the validator's lowest acceptable value

Returns a built-in Qt signal QIntValidator::bottomChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

This property holds the validator's lowest acceptable value

By default, this property's value is derived from the lowest signed integer available (typically -2147483647).

Access functions:

int bottom() const
void setBottom(int)

Notifier signal:

void bottomChanged(int bottom)

See also setRange().

pub fn top_changed(&self) -> Signal<(c_int,)>[src]

This property holds the validator's highest acceptable value

Returns a built-in Qt signal QIntValidator::topChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

This property holds the validator's highest acceptable value

By default, this property's value is derived from the highest signed integer available (typically 2147483647).

Access functions:

int top() const
void setTop(int)

Notifier signal:

void topChanged(int top)

See also setRange().

pub unsafe fn bottom(&self) -> c_int[src]

This property holds the validator's lowest acceptable value

Calls C++ function: int QIntValidator::bottom() const.

C++ documentation:

This property holds the validator's lowest acceptable value

By default, this property's value is derived from the lowest signed integer available (typically -2147483647).

Access functions:

int bottom() const
void setBottom(int)

See also setRange().

pub unsafe fn fixup(&self, input: impl CastInto<Ref<QString>>)[src]

Reimplemented from QValidator::fixup().

Calls C++ function: virtual void QIntValidator::fixup(QString& input) const.

C++ documentation:

Reimplemented from QValidator::fixup().

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QIntValidator::metaObject() const.

pub unsafe fn new_1a(parent: impl CastInto<Ptr<QObject>>) -> QBox<QIntValidator>[src]

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

Calls C++ function: [constructor] void QIntValidator::QIntValidator(QObject* parent = …).

C++ documentation:

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

pub unsafe fn new_3a(
    bottom: c_int,
    top: c_int,
    parent: impl CastInto<Ptr<QObject>>
) -> QBox<QIntValidator>
[src]

Constructs a validator with a parent, that accepts integers from minimum to maximum inclusive.

Calls C++ function: [constructor] void QIntValidator::QIntValidator(int bottom, int top, QObject* parent = …).

C++ documentation:

Constructs a validator with a parent, that accepts integers from minimum to maximum inclusive.

pub unsafe fn new_0a() -> QBox<QIntValidator>[src]

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

Calls C++ function: [constructor] void QIntValidator::QIntValidator().

C++ documentation:

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, 900, this);

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

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

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

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

Notice that the value 999 returns Intermediate. Values consisting of a number of digits equal to or less than the max value are considered intermediate. This is intended because the digit that prevents a number from being in range is not necessarily the last digit typed. This also means that an intermediate number can have leading zeros.

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.

Note: The QLocale::NumberOptions set on the locale() also affect the way the number is interpreted. For example, since QLocale::RejectGroupSeparator is not set by default, the validator will accept group separators. It is thus recommended to use QLocale::toInt() to obtain the numeric value.

pub unsafe fn new_2a(bottom: c_int, top: c_int) -> QBox<QIntValidator>[src]

Constructs a validator with a parent, that accepts integers from minimum to maximum inclusive.

Calls C++ function: [constructor] void QIntValidator::QIntValidator(int bottom, int top).

C++ documentation:

Constructs a validator with a parent, that accepts integers from minimum to maximum inclusive.

pub unsafe fn qt_metacall(
    &self,
    arg1: Call,
    arg2: c_int,
    arg3: *mut *mut c_void
) -> c_int
[src]

Calls C++ function: virtual int QIntValidator::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void[src]

Calls C++ function: virtual void* QIntValidator::qt_metacast(const char* arg1).

pub unsafe fn set_bottom(&self, arg1: c_int)[src]

This property holds the validator's lowest acceptable value

Calls C++ function: void QIntValidator::setBottom(int arg1).

C++ documentation:

This property holds the validator's lowest acceptable value

By default, this property's value is derived from the lowest signed integer available (typically -2147483647).

Access functions:

int bottom() const
void setBottom(int)

See also setRange().

pub unsafe fn set_range(&self, bottom: c_int, top: c_int)[src]

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

Calls C++ function: virtual void QIntValidator::setRange(int bottom, int top).

C++ documentation:

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

pub unsafe fn set_top(&self, arg1: c_int)[src]

This property holds the validator's highest acceptable value

Calls C++ function: void QIntValidator::setTop(int arg1).

C++ documentation:

This property holds the validator's highest acceptable value

By default, this property's value is derived from the highest signed integer available (typically 2147483647).

Access functions:

int top() const
void setTop(int)

See also setRange().

pub unsafe fn static_meta_object() -> Ref<QMetaObject>[src]

Returns a reference to the staticMetaObject field.

pub unsafe fn top(&self) -> c_int[src]

This property holds the validator's highest acceptable value

Calls C++ function: int QIntValidator::top() const.

C++ documentation:

This property holds the validator's highest acceptable value

By default, this property's value is derived from the highest signed integer available (typically 2147483647).

Access functions:

int top() const
void setTop(int)

See also setRange().

pub unsafe fn tr(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QIntValidator::tr(const char* s, const char* c, int n).

pub unsafe fn tr_utf8(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QIntValidator::trUtf8(const char* s, const char* c, int n).

pub unsafe fn validate(
    &self,
    arg1: impl CastInto<Ref<QString>>,
    arg2: *mut c_int
) -> State
[src]

Reimplemented from QValidator::validate().

Calls C++ function: virtual QValidator::State QIntValidator::validate(QString& arg1, int& arg2) const.

C++ documentation:

Reimplemented from QValidator::validate().

Returns Acceptable if the input is an integer within the valid range, Intermediate if the input is a prefix of an integer in the valid range, and Invalid otherwise.

If the valid range consists of just positive integers (e.g., 32 to 100) and input is a negative integer, then Invalid is returned. (On the other hand, if the range consists of negative integers (e.g., -100 to -32) and input is a positive integer, then Intermediate is returned, because the user might be just about to type the minus (especially for right-to-left languages).

int pos = 0;

s = "abc"; v.validate(s, pos); // returns Invalid

s = "5"; v.validate(s, pos); // returns Intermediate

s = "50"; v.validate(s, pos); // returns Acceptable

By default, the pos parameter is not used by this validator.

Methods from Deref<Target = QValidator>

pub fn changed(&self) -> Signal<()>[src]

This signal is emitted when any property that may affect the validity of a string has changed.

Returns a built-in Qt signal QValidator::changed that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted when any property that may affect the validity of a string has changed.

pub unsafe fn fixup(&self, arg1: impl CastInto<Ref<QString>>)[src]

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.

Calls C++ function: virtual void QValidator::fixup(QString& arg1) const.

C++ documentation:

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.

pub unsafe fn locale(&self) -> CppBox<QLocale>[src]

Returns the locale for the validator. The locale is by default initialized to the same as QLocale().

Calls C++ function: QLocale QValidator::locale() const.

C++ documentation:

Returns the locale for the validator. The locale is by default initialized to the same as QLocale().

See also setLocale() and QLocale::QLocale().

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QValidator::metaObject() const.

pub unsafe fn qt_metacall(
    &self,
    arg1: Call,
    arg2: c_int,
    arg3: *mut *mut c_void
) -> c_int
[src]

Calls C++ function: virtual int QValidator::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void[src]

Calls C++ function: virtual void* QValidator::qt_metacast(const char* arg1).

pub unsafe fn set_locale(&self, locale: impl CastInto<Ref<QLocale>>)[src]

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.

Calls C++ function: void QValidator::setLocale(const QLocale& locale).

C++ documentation:

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.

See also locale() and QLocale::setDefault().

pub unsafe fn validate(
    &self,
    arg1: impl CastInto<Ref<QString>>,
    arg2: *mut c_int
) -> State
[src]

This 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.

Calls C++ function: pure virtual QValidator::State QValidator::validate(QString& arg1, int& arg2) const.

C++ documentation:

This 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 both input and pos (the cursor position) if required.

Trait Implementations

impl CppDeletable for QIntValidator[src]

unsafe fn delete(&self)[src]

Destroys the validator.

Calls C++ function: virtual [destructor] void QIntValidator::~QIntValidator().

C++ documentation:

Destroys the validator.

impl Deref for QIntValidator[src]

type Target = QValidator

The resulting type after dereferencing.

fn deref(&self) -> &QValidator[src]

Calls C++ function: QValidator* static_cast<QValidator*>(QIntValidator* ptr).

impl DynamicCast<QIntValidator> for QValidator[src]

unsafe fn dynamic_cast(ptr: Ptr<QValidator>) -> Ptr<QIntValidator>[src]

Calls C++ function: QIntValidator* dynamic_cast<QIntValidator*>(QValidator* ptr).

impl DynamicCast<QIntValidator> for QObject[src]

unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QIntValidator>[src]

Calls C++ function: QIntValidator* dynamic_cast<QIntValidator*>(QObject* ptr).

impl StaticDowncast<QIntValidator> for QValidator[src]

unsafe fn static_downcast(ptr: Ptr<QValidator>) -> Ptr<QIntValidator>[src]

Calls C++ function: QIntValidator* static_cast<QIntValidator*>(QValidator* ptr).

impl StaticDowncast<QIntValidator> for QObject[src]

unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QIntValidator>[src]

Calls C++ function: QIntValidator* static_cast<QIntValidator*>(QObject* ptr).

impl StaticUpcast<QObject> for QIntValidator[src]

unsafe fn static_upcast(ptr: Ptr<QIntValidator>) -> Ptr<QObject>[src]

Calls C++ function: QObject* static_cast<QObject*>(QIntValidator* ptr).

impl StaticUpcast<QValidator> for QIntValidator[src]

unsafe fn static_upcast(ptr: Ptr<QIntValidator>) -> Ptr<QValidator>[src]

Calls C++ function: QValidator* static_cast<QValidator*>(QIntValidator* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.