PySide.QtCore.QPoint class defines a point in the plane using integer precision.
A point is specified by a x coordinate and an y coordinate which can be accessed using the PySide.QtCore.QPoint.x() and PySide.QtCore.QPoint.y() functions. The PySide.QtCore.QPoint.isNull() function returns true if both x and y are set to 0. The coordinates can be set (or altered) using the PySide.QtCore.QPoint.setX() and PySide.QtCore.QPoint.setY() functions, or alternatively the PySide.QtCore.QPoint.rx() and PySide.QtCore.QPoint.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 PySide.QtCore.QPoint object can also be used as a vector: Addition and subtraction are defined as for vectors (each component is added separately). A PySide.QtCore.QPoint object can also be divided or multiplied by an int 或 qreal .
此外, PySide.QtCore.QPoint class provides the PySide.QtCore.QPoint.manhattanLength() function which gives an inexpensive approximation of the length of the PySide.QtCore.QPoint object interpreted as a vector. Finally, PySide.QtCore.QPoint objects can be streamed as well as compared.
| 参数: |
|
|---|
Constructs a null point, i.e. with coordinates (0, 0)
构造点采用给定坐标 ( x , y ).
| 返回类型: | PyObject |
|---|
| 返回类型: | PyObject |
|---|
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if both the x and y coordinates are set to 0, otherwise returns false.
| 返回类型: | PySide.QtCore.int |
|---|
Returns the sum of the absolute values of PySide.QtCore.QPoint.x() and PySide.QtCore.QPoint.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.
| 参数: | p2 – PySide.QtCore.QPoint |
|---|---|
| 返回类型: | PySide.QtCore.bool |
| 参数: | c – PySide.QtCore.float |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
| 参数: | c – PySide.QtCore.double |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
| 参数: | c – PySide.QtCore.float |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
| 参数: | c – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
| 参数: | c – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
| 参数: | matrix – PySide.QtGui.QMatrix4x4 |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
| 参数: | m – PySide.QtGui.QMatrix |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
| 参数: | c – PySide.QtCore.double |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
| 参数: | matrix – PySide.QtGui.QMatrix4x4 |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
| 参数: | m – PySide.QtGui.QTransform |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
| 参数: | c – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
Multiplies this point's coordinates by the given factor , and returns a reference to this point.
另请参阅
PySide.QtCore.QPoint.operator/=()
| 参数: | c – PySide.QtCore.double |
|---|---|
| 返回类型: | PySide.QtCore.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 PySide.QtCore.QPointF for floating point accuracy.
另请参阅
PySide.QtCore.QPoint.operator/=()
| 参数: | c – PySide.QtCore.float |
|---|---|
| 返回类型: | PySide.QtCore.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 PySide.QtCore.QPointF for floating point accuracy.
另请参阅
PySide.QtCore.QPoint.operator/=()
| 参数: | p2 – PySide.QtCore.QPoint |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
| 参数: | p – PySide.QtCore.QPoint |
|---|---|
| 返回类型: | PySide.QtCore.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)
另请参阅
PySide.QtCore.QPoint.operator-=()
| 参数: | p2 – PySide.QtCore.QPoint |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
| 返回类型: | PySide.QtCore.QPoint |
|---|
| 参数: | p – PySide.QtCore.QPoint |
|---|---|
| 返回类型: | PySide.QtCore.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)
另请参阅
PySide.QtCore.QPoint.operator+=()
| 参数: | c – PySide.QtCore.qreal |
|---|---|
| 返回类型: | PySide.QtCore.QPoint |
| 参数: | c – PySide.QtCore.qreal |
|---|---|
| 返回类型: | PySide.QtCore.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 PySide.QtCore.QPointF for floating point accuracy.
另请参阅
PySide.QtCore.QPoint.operator*=()
| 参数: | p2 – PySide.QtCore.QPoint |
|---|---|
| 返回类型: | PySide.QtCore.bool |
| 参数: | x – PySide.QtCore.int |
|---|
Sets the x coordinate of this point to the given x 坐标。
| 参数: | y – PySide.QtCore.int |
|---|
Sets the y coordinate of this point to the given y 坐标。
| 返回类型: | PyObject |
|---|
| 返回类型: | PySide.QtCore.int |
|---|
返回此点的 x 坐标。
另请参阅
PySide.QtCore.QPoint.setX() PySide.QtCore.QPoint.rx()
| 返回类型: | PySide.QtCore.int |
|---|
返回此点的 y 坐标。
另请参阅
PySide.QtCore.QPoint.setY() PySide.QtCore.QPoint.ry()