- Qt 6.11
- Qt Quick
- QML Types
- IntValidator
- Qt 6.11.1 Reference Documentation

# IntValidator QML Type

Defines a validator for integer values. More...

Import Statement: | `import QtQuick`

- List of all members, including inherited members

## Properties

- bottom : int
- locale : string
- top : int

## Detailed Description

The IntValidator type provides a validator for integer values.

If no locale is set IntValidator uses the default locale to interpret the number and will accept locale specific digits, group separators, and positive and negative signs. In addition, IntValidator is always guaranteed to accept a number formatted according to the "C" locale.

The following example shows a TextInput object with an IntValidator to check that the user has input an integer within the specified range, updating the text color to highlight invalid input:

     import QtQuick

     TextInput {
         focus: true
         validator: IntValidator {
             bottom: 0
             top: 100
         }
         color: acceptableInput ? "black" : "red";
     }

The validator will prevent the submission of text which can't possibly be valid. However, while editing, only easily identified invalidity will be blocked, for example sign conflicts or too many non-zero digits. This can sometimes be surprising. The validator in the example above will for instance allow entering "999", as values consisting of a number of digits equal to or less than the max value are considered "intermediate" – meaning that they are in a state where they are not valid, but could be adjusted to be so. 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.

Adding a visual indicator based on TextInput's acceptableInput property can make clear to the user whether what they've typed will actually be accepted.

See also DoubleValidator, RegularExpressionValidator, and Validating Input Text.

## Property Documentation

### bottom : int

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

### locale : string

This property holds the name of the locale used to interpret the number.

See also Qt.locale().

### top : int

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