内容表

上一话题

QPluginLoader

下一话题

QPointF

QPoint

QPoint class defines a point in the plane using integer precision. 更多

Inheritance diagram of PySide2.QtCore.QPoint

概要

函数

静态函数

详细描述

A point is specified by a x coordinate and an y coordinate which can be accessed using the x() and y() functions. The isNull() function returns true if both x and y are set to 0. The coordinates can be set (or altered) using the setX() and setY() functions, or alternatively the rx() and ry() functions which return references to the coordinates (allowing direct manipulation).

Given a point p , the following statements are all equivalent:

p = QPoint()
p.setX(p.x() + 1)
p += QPoint(1, 0)
											

A QPoint object can also be used as a vector: Addition and subtraction are defined as for vectors (each component is added separately). A QPoint object can also be divided or multiplied by an int qreal .

此外, QPoint class provides the manhattanLength() function which gives an inexpensive approximation of the length of the QPoint object interpreted as a vector. Finally, QPoint objects can be streamed as well as compared.

class QPoint

QPoint(QPoint)

QPoint(xpos, ypos)

param QPoint

QPoint

param ypos

int

param xpos

int

Constructs a null point, i.e. with coordinates (0, 0)

另请参阅

isNull()

构造点采用给定坐标 ( xpos , ypos ).

另请参阅

setX() setY()

PySide2.QtCore.QPoint. __reduce__ ( )
返回类型

PyObject

PySide2.QtCore.QPoint. __repr__ ( )
返回类型

PyObject

static PySide2.QtCore.QPoint. dotProduct ( p1 , p2 )
参数
返回类型

int

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 .

PySide2.QtCore.QPoint. isNull ( )
返回类型

bool

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

PySide2.QtCore.QPoint. manhattanLength ( )
返回类型

int

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:

class MyWidget(QWidget):
    self.oldPosition = QPointer()
    # event : QMouseEvent
    def mouseMoveEvent(QMouseEvent event):
        point = event.pos() - self.oldPosition
        if (point.manhattanLength() > 3):
            # the mouse has moved more than 3 pixels since the oldPosition
            pass
											

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

trueLength = sqrt(pow(x(), 2) + 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.

PySide2.QtCore.QPoint. __ne__ ( p2 )
参数

p2 QPoint

返回类型

bool

PySide2.QtCore.QPoint. __mul__ ( matrix )
参数

matrix QMatrix4x4

返回类型

QPoint

PySide2.QtCore.QPoint. __mul__ ( factor )
参数

factor int

返回类型

QPoint

PySide2.QtCore.QPoint. __mul__ ( factor )
参数

factor int

返回类型

QPoint

PySide2.QtCore.QPoint. __mul__ ( factor )
参数

factor float

返回类型

QPoint

PySide2.QtCore.QPoint. __mul__ ( factor )
参数

factor float

返回类型

QPoint

PySide2.QtCore.QPoint. __mul__ ( factor )
参数

factor double

返回类型

QPoint

PySide2.QtCore.QPoint. __mul__ ( factor )
参数

factor double

返回类型

QPoint

PySide2.QtCore.QPoint. __mul__ ( m )
参数

m QTransform

返回类型

QPoint

PySide2.QtCore.QPoint. __mul__ ( matrix )
参数

matrix QMatrix4x4

返回类型

QPoint

PySide2.QtCore.QPoint. __mul__ ( m )
参数

m QMatrix

返回类型

QPoint

PySide2.QtCore.QPoint. __imul__ ( factor )
参数

factor double

返回类型

QPoint

Multiplies this point’s coordinates by the given factor , and returns a reference to this point. For example:

p = QPoint(-1, 4)
p *= 2.5  # p becomes (-3, 10)
											

Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.

另请参阅

operator/=()

PySide2.QtCore.QPoint. __imul__ ( factor )
参数

factor int

返回类型

QPoint

Multiplies this point’s coordinates by the given factor , and returns a reference to this point.

另请参阅

operator/=()

PySide2.QtCore.QPoint. __imul__ ( factor )
参数

factor float

返回类型

QPoint

Multiplies this point’s coordinates by the given factor , and returns a reference to this point.

Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.

另请参阅

operator/=()

PySide2.QtCore.QPoint. __add__ ( )
返回类型

QPoint

PySide2.QtCore.QPoint. __add__ ( p2 )
参数

p2 QPoint

返回类型

QPoint

PySide2.QtCore.QPoint. __iadd__ ( p )
参数

p QPoint

返回类型

QPoint

添加给定 point to this point and returns a reference to this point. For example:

p = QPoint( 3, 7)
q = QPoint(-1, 4)
p += q    # p becomes (2, 11)
											

另请参阅

operator-=()

PySide2.QtCore.QPoint. __sub__ ( )
返回类型

QPoint

PySide2.QtCore.QPoint. __sub__ ( p2 )
参数

p2 QPoint

返回类型

QPoint

PySide2.QtCore.QPoint. __isub__ ( p )
参数

p QPoint

返回类型

QPoint

Subtracts the given point from this point and returns a reference to this point. For example:

p = QPoint( 3, 7)
q = QPoint(-1, 4)
p -= q    # p becomes (4, 3)
											

另请参阅

operator+=()

PySide2.QtCore.QPoint. __div__ ( c )
参数

c qreal

返回类型

QPoint

PySide2.QtCore.QPoint. __idiv__ ( divisor )
参数

divisor qreal

返回类型

QPoint

这是重载函数。

Divides both x and y by the given divisor , and returns a reference to this point. For example:

p = QPoint(-3, 10)
p /= 2.5  # p becomes (-1, 4)
											

Note that the result is rounded to the nearest integer as points are held as integers. Use QPointF for floating point accuracy.

另请参阅

operator*=()

PySide2.QtCore.QPoint. __eq__ ( p2 )
参数

p2 QPoint

返回类型

bool

PySide2.QtCore.QPoint. setX ( x )
参数

x int

Sets the x coordinate of this point to the given x 坐标。

另请参阅

x() setY()

PySide2.QtCore.QPoint. setY ( y )
参数

y int

Sets the y coordinate of this point to the given y 坐标。

另请参阅

y() setX()

PySide2.QtCore.QPoint. toTuple ( )
返回类型

PyObject

PySide2.QtCore.QPoint. transposed ( )
返回类型

QPoint

Returns a point with x and y coordinates exchanged:

QPoint{1, 2}.transposed() // {2, 1}
											
PySide2.QtCore.QPoint. x ( )
返回类型

int

返回此点的 x 坐标。

另请参阅

setX() rx()

PySide2.QtCore.QPoint. y ( )
返回类型

int

返回此点的 y 坐标。

另请参阅

setY() ry()