Skip to content

IntValidator

Base classes

Name Children Inherits
ValidatorMixin
prettyqt.gui.validator
QIntValidator
PySide6.QtGui
QIntValidator(self, /, parent: PySide6.QtCore.QObject | None \= None, *, bottom: int | None \= None, top: int | None \= None) -> None

⋔ Inheritance diagram

graph TD
  2505848740["gui.IntValidator"]
  1804432572["gui.ValidatorMixin"]
  3227531497["core.ObjectMixin"]
  2751680898["builtins.object"]
  1957902365["QtGui.QIntValidator"]
  49520861["QtGui.QValidator"]
  3984060476["QtCore.QObject"]
  37984305["Shiboken.Object"]
  1804432572 --> 2505848740
  3227531497 --> 1804432572
  2751680898 --> 3227531497
  2751680898 --> 1804432572
  1957902365 --> 2505848740
  49520861 --> 1957902365
  3984060476 --> 49520861
  37984305 --> 3984060476
  2751680898 --> 37984305

🛈 DocStrings

Bases: ValidatorMixin, QIntValidator

Validator that ensures a string contains a integer within a specified range.

Source code in prettyqt/gui/intvalidator.py
class IntValidator(gui.ValidatorMixin, gui.QIntValidator):
    """Validator that ensures a string contains a integer within a specified range."""

    ID = "integer_classic"

    def __repr__(self):
        return get_repr(self, self.bottom(), self.top())

    def __getstate__(self):
        return dict(bottom=self.bottom(), top=self.top())

    def __reduce__(self):
        return type(self), (self.bottom(), self.top()), None

    def __eq__(self, other: object):
        return (
            self.bottom() == other.bottom() and self.top() == other.top()
            if isinstance(other, type(self))
            else False
        )

    def set_range(self, lower: int | None, upper: int | None):
        if lower is None:
            lower = -MAX_VAL
        if upper is None:
            upper = MAX_VAL
        self.setRange(lower, upper)

:fa-brands-github: Show source on GitHub