QPoint Class Reference

[QtCore module]

该QPoint类定义使用整数精度在平面上的一个点。More…

Methods

  • __init__ (self)
  • __init__ (self, int xpos, int ypos)
  • __init__ (self, QPoint)
  • bool isNull (self)
  • int manhattanLength (self)
  • setX (self, int xpos)
  • setY (self, int ypos)
  • int x (self)
  • int y (self)

Special Methods

  • QPoint __mul__ (self, QMatrix m)
  • QPoint __mul__ (self, QMatrix4x4 matrix)
  • QPoint __mul__ (self, QTransform m)
  • QPoint __add__ (self, QPoint p2)
  • int __bool__ (self)
  • QPoint __div__ (self, float c)
  • bool __eq__ (self, QPoint p2)
  • QPoint __iadd__ (self, QPoint p)
  • QPoint __idiv__ (self, float c)
  • QPoint __imul__ (self, int c)
  • QPoint __imul__ (self, float c)
  • QPoint __isub__ (self, QPoint p)
  • QPoint __mul__ (self, int c)
  • QPoint __mul__ (self, QPoint p)
  • QPoint __mul__ (self, float c)
  • QPoint __mul__ (self, QPoint p)
  • bool __ne__ (self, QPoint p2)
  • QPoint __neg__ (self)
  • str __repr__ (self)
  • QPoint __sub__ (self, QPoint p2)

Detailed Description

这个类可以醃制。

该QPoint类定义使用整数精度在平面上的一个点。

被指定的点由斧头协调和使用y坐标可接的x()和y()函数。该isNull如果x和y都设置为0 ()函数返回真。坐标可以使用设置(或改变)的setX()和setY()函数,或者在rx()和ry( ),它返回引用到坐标(允许直接操作)等功能。

给定一个点p,下面的语句是等价的:

  1. QPoint p;
  2. p.setX(p.x() + 1);
  3. p += QPoint(1, 0);
  4. p.rx()++;

甲QPoint对象也可以被用作载体:加法和减法的定义为矢量(每个组分单独加入) 。一个QPoint对象也可以通过分频或倍频intqreal

此外, QPoint类提供manhattanLength()函数,它给出了QPoint物体的长度的一种廉价的近似解释为一个向量。最后,相比QPoint对象可以被串流播放,以及。


Method Documentation

  1. QPoint.__init__ (self)

构造一个零点,即坐标为( 0,0)

See also isNull( ) 。

  1. QPoint.__init__ (self, int xpos, int ypos)

构造一个点与给定的坐标(xy) 。

See also setX()和setY( ) 。

  1. QPoint.__init__ (self, QPoint)
  1. bool QPoint.isNull (self)

返回True如果x和y坐标都设置为0 ,否则返回False 。

  1. int QPoint.manhattanLength (self)

返回的绝对值之和x()和y( ) ,传统上被称为“曼哈顿长度”从原点的向量的点。例如:

  1. [QPoint](qpoint.html) oldPosition;
  2. MyWidget.mouseMoveEvent([QMouseEvent](qmouseevent.html) *event)
  3. {
  4. [QPoint](qpoint.html) point = event->pos() - oldPosition;
  5. if (point.manhattanLength() > 3)
  6. // the mouse has moved more than 3 pixels since the oldPosition
  7. }

这是一个有用的,快速的计算,近似真实的长度:

  1. double trueLength = sqrt(pow(x(), 2) + pow(y(), 2));

“曼哈顿长度”的传统产生,是因为这样的距离适用于旅客谁只能行驶在矩形网格,就像曼哈顿的大街上。

  1. QPoint.setX (self, int xpos)

设置该点的x坐标,以给定的x协调。

See also x()和setY( ) 。

  1. QPoint.setY (self, int ypos)

设置该点的y坐标为给定的y协调。

See also y()和setX( ) 。

  1. int QPoint.x (self)

返回该点的x坐标。

See also setX()和rx( ) 。

  1. int QPoint.y (self)

返回此点的y坐标。

See also setY()和ry( ) 。

  1. QPoint __mul__ (self, QMatrix m)

[

如果QtGui模块导入此方法仅适用。

](qpoint.html)

  1. QPoint __mul__ (self, QMatrix4x4 matrix)

[

如果QtGui模块导入此方法仅适用。

](qpoint.html)

  1. QPoint __mul__ (self, QTransform m)

[

如果QtGui模块导入此方法仅适用。

](qpoint.html)

  1. QPoint QPoint.__add__ (self, QPoint p2)

[

  1. int QPoint.__bool__ (self)

](qpoint.html)

  1. QPoint QPoint.__div__ (self, float c)

[

  1. bool QPoint.__eq__ (self, QPoint p2)

](qpoint.html)

  1. QPoint QPoint.__iadd__ (self, QPoint p)

  1. QPoint QPoint.__idiv__ (self, float c)

  1. QPoint QPoint.__imul__ (self, int c)

  1. QPoint QPoint.__imul__ (self, float c)

  1. QPoint QPoint.__isub__ (self, QPoint p)

  1. QPoint QPoint.__mul__ (self, int c)

  1. QPoint QPoint.__mul__ (self, QPoint p)

  1. QPoint QPoint.__mul__ (self, float c)

  1. QPoint QPoint.__mul__ (self, QPoint p)

[

  1. bool QPoint.__ne__ (self, QPoint p2)

](qpoint.html)

  1. QPoint QPoint.__neg__ (self)

[

  1. str QPoint.__repr__ (self)

](qpoint.html)

  1. QPoint QPoint.__sub__ (self, QPoint p2)