Skip to content

FloatListValidator

Qt Base Class: QValidator

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

Base classes

Name Children Inherits
BaseRegexValidator
prettyqt.validators.regexvalidators

⋔ Inheritance diagram

graph TD
  1473367023792["validators.FloatListValidator"]
  1473367026720["validators.BaseRegexValidator"]
  1473245568976["gui.Validator"]
  1473245536768["gui.ValidatorMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473289208592["QtGui.QValidator"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473367026720 --> 1473367023792
  1473245568976 --> 1473367026720
  1473245536768 --> 1473245568976
  1473299815024 --> 1473245536768
  140713234304496 --> 1473299815024
  1473289208592 --> 1473245568976
  1473288842240 --> 1473289208592
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208

🛈 DocStrings

Bases: BaseRegexValidator

Validator which checks whether given string is a comma-separated list of floats.

Source code in prettyqt\validators\regexvalidators.py
class FloatListValidator(BaseRegexValidator):
    """Validator which checks whether given string is a comma-separated list of floats."""

    ID = "float_list"

    def __init__(self, allow_single: bool = True, parent: QtCore.QObject | None = None):
        super().__init__(parent=parent)
        self.allow_single = allow_single
        if allow_single:
            self.set_regex(r"^(\s*-?\d+(\.\d+)?)(\s*,\s*-?\d+(\.\d+)?)*$")
        else:
            self.set_regex(
                r"^(\s*-?\d+(\.\d+)?)(\s*,\s*-?\d+(\.\d+)?)(\s*,\s*-?\d+(\.\d+)?)*$"
            )

    def __reduce__(self):
        return type(self), (self.allow_single,)

    def __repr__(self):
        return get_repr(self, allow_single=self.allow_single)

⌗ Property table

Qt Property Type Doc
objectName QString

Validator ID: float_list