Skip to content

PythonQt.QtCore.QPoint · declarations 001

Back to PythonQt.QtCore.QPoint

dotProduct

dotProduct(p1: Any, p2: Any) -> int

X.dotProduct(p1, p2) -> int

Supplemental documentation: Qt 5 reference:

[static] int QPoint::dotProduct(const QPoint \&p1, const QPoint \&p2)

QPoint p( 3, 7);
QPoint q(-1, 4);
int lengthSquared = QPoint::dotProduct(p, q);   // lengthSquared becomes 25

Returns the dot product of p1 and p2.

This function was introduced in Qt 5.1.

Upstream PySide2 reference signatures (binding differences may apply):

dotProduct(p1: PySide2.QtCore.QPoint, p2: PySide2.QtCore.QPoint) -> int

Source: https://doc.qt.io/archives/qt-5.15/qpoint.html#dotProduct

isNull

isNull() -> bool

X.isNull() -> bool

Supplemental documentation: Qt 5 reference:

bool QPoint::isNull() const

Returns true if both the x and y coordinates are set to 0, otherwise returns false.

Upstream PySide2 reference signatures (binding differences may apply):

isNull(self) -> bool

Source: https://doc.qt.io/archives/qt-5.15/qpoint.html#isNull

manhattanLength

manhattanLength() -> int

X.manhattanLength() -> int

Supplemental documentation: Qt 5 reference:

int QPoint::manhattanLength() const

Returns the sum of the absolute values of x() and y(), traditionally known as the "Manhattan length" of the vector from the origin to the point. For example:

QPoint oldPosition;

MyWidget::mouseMoveEvent(QMouseEvent *event)
{
    QPoint point = event->pos() - oldPosition;
    if (point.manhattanLength() > 3)
        // the mouse has moved more than 3 pixels since the oldPosition
}

This is a useful, and quick to calculate, approximation to the true length:

double trueLength = std::sqrt(std::pow(x(), 2) + std::pow(y(), 2));

The tradition of "Manhattan length" arises because such distances apply to travelers who can only travel on a rectangular grid, like the streets of Manhattan.

Upstream PySide2 reference signatures (binding differences may apply):

manhattanLength(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qpoint.html#manhattanLength

setX

setX(x: int) -> None

X.setX(x)

Supplemental documentation: Qt 5 reference:

void QPoint::setX(int x)

Sets the x coordinate of this point to the given x coordinate.

See also x() and setY().

Upstream PySide2 reference signatures (binding differences may apply):

setX(self, x: int) -> None

Source: https://doc.qt.io/archives/qt-5.15/qpoint.html#setX

setY

setY(y: int) -> None

X.setY(y)

Supplemental documentation: Qt 5 reference:

void QPoint::setY(int y)

Sets the y coordinate of this point to the given y coordinate.

See also y() and setX().

Upstream PySide2 reference signatures (binding differences may apply):

setY(self, y: int) -> None

Source: https://doc.qt.io/archives/qt-5.15/qpoint.html#setY

x

x() -> int

X.x() -> int

Supplemental documentation: Qt 5 reference:

int QPoint::x() const

Returns the x coordinate of this point.

See also setX() and rx().

Upstream PySide2 reference signatures (binding differences may apply):

x(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qpoint.html#x

y

y() -> int

X.y() -> int

Supplemental documentation: Qt 5 reference:

int QPoint::y() const

Returns the y coordinate of this point.

See also setY() and ry().

Upstream PySide2 reference signatures (binding differences may apply):

y(self) -> int

Source: https://doc.qt.io/archives/qt-5.15/qpoint.html#y