Skip to content

Vector2D

Base classes

Name Children Inherits
QVector2D
PySide6.QtGui
QVector2D(self, /) -> None

⋔ Inheritance diagram

graph TD
  981118343["gui.Vector2D"]
  3486443913["QtGui.QVector2D"]
  37984305["Shiboken.Object"]
  2751680898["builtins.object"]
  3486443913 --> 981118343
  37984305 --> 3486443913
  2751680898 --> 37984305

🛈 DocStrings

Bases: QVector2D

Represents a vector or vertex in 2D space.

Source code in prettyqt/gui/vector2d.py
class Vector2D(QtGui.QVector2D):
    """Represents a vector or vertex in 2D space."""

    def __bool__(self):
        return not self.isNull()

    def __abs__(self) -> float:
        return self.length()

    @property
    def _x(self) -> float:
        return self.x()

    @property
    def _y(self) -> float:
        return self.y()

    __match_args__ = ("_x", "_y")

    def __reduce__(self):
        return type(self), (self.x(), self.y())

    def to_point(self) -> core.Point:
        return core.Point(self.toPoint())

    def to_pointf(self) -> core.PointF:
        return core.PointF(self.toPointF())

    def to_vector3d(self) -> gui.Vector3D:
        return gui.Vector3D(self.toVector3D())

    def to_vector4d(self) -> gui.Vector4D:
        return gui.Vector4D(self.toVector4D())

:fa-brands-github: Show source on GitHub