Skip to content

AlphaNumericValidator

Qt Base Class: QValidator

Signature: QValidator(self, parent: Optional[PySide6.QtCore.QObject] = None) -> None

Base classes

⋔ Inheritance diagram

🛈 DocStrings

Bases: Validator

Validator which checks whether only alphanumeric characters are included.

Source code in prettyqt\validators\alphanumericvalidator.py
class AlphaNumericValidator(gui.Validator):
    """Validator which checks whether only alphanumeric characters are included."""

    ID = "alphanumeric"

    def __eq__(self, other: object):
        return isinstance(other, AlphaNumericValidator)

    def validate(self, text: str, pos: int = 0):
        if text.replace("_", "").isalnum():
            return self.State.Acceptable, text, pos
        return self.State.Invalid, text, pos

⌗ Property table

Qt Property Type Doc
objectName QString

Validator ID: alphanumeric