Qyoto  4.0.6
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtCore.QPoint Class Reference

The QPoint class defines a point in the plane using integer precision. More...

Inheritance diagram for QtCore.QPoint:
Collaboration diagram for QtCore.QPoint:

Public Member Functions

override bool Equals (object o)
 
override int GetHashCode ()
 
 QPoint ()
 
 
 QPoint (QPoint copy)
 
 QPoint (int xpos, int ypos)
 
 
virtual void CreateProxy ()
 
new void Dispose ()
 

Static Public Member Functions

static bool operator!= (QPoint p1, QPoint p2)
 
 
static QPoint operator* (QPoint p, float c)
 
 
static QPoint operator* (QPoint p, double c)
 
 
static QPoint operator* (QPoint p, int c)
 
 
static QPoint operator+ (QPoint p1, QPoint p2)
 
 
static QPoint operator- (QPoint p)
 
 
static QPoint operator- (QPoint p1, QPoint p2)
 
 
static QPoint operator/ (QPoint p, double c)
 
 
static bool operator== (QPoint p1, QPoint p2)
 
 

Protected Member Functions

 QPoint (System.Type dummy)
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

int X [get, set]
 
 
int Y [get, set]
 
 
bool IsNull [get]
 
 
int ManhattanLength [get]
 
 
int Rx [get]
 
 
int Ry [get]
 
 
virtual System.IntPtr SmokeObject [get, set]
 

Detailed Description

The 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 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:

QPoint p;

p.setX(p.x() + 1);

p += QPoint(1, 0);

p.rx()++;

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 or a qreal.

In addition, the 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.

See also QPointF and QPolygon.

Constructor & Destructor Documentation

QtCore.QPoint.QPoint ( System.Type  dummy)
protected
QtCore.QPoint.QPoint ( )

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

See also isNull().

QtCore.QPoint.QPoint ( QPoint  copy)
QtCore.QPoint.QPoint ( int  xpos,
int  ypos 
)

Constructs a point with the given coordinates (x, y).

See also setX() and setY().

Member Function Documentation

virtual void QtCore.QPoint.CreateProxy ( )
virtual
new void QtCore.QPoint.Dispose ( )
override bool QtCore.QPoint.Equals ( object  o)
override int QtCore.QPoint.GetHashCode ( )
static bool QtCore.QPoint.operator!= ( QPoint  p1,
QPoint  p2 
)
static

Returns true if p1 and p2 are not equal; otherwise returns false.

static QPoint QtCore.QPoint.operator* ( QPoint  p,
float  c 
)
static

Returns a copy of the given point multiplied by the given factor.

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

This function was introduced in Qt 4.8.

See also QPoint::operator*=().

static QPoint QtCore.QPoint.operator* ( QPoint  p,
double  c 
)
static

Returns a copy of the given point multiplied by the given factor.

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

This function was introduced in Qt 4.8.

See also QPoint::operator*=().

static QPoint QtCore.QPoint.operator* ( QPoint  p,
int  c 
)
static

Returns a copy of the given point multiplied by the given factor.

This function was introduced in Qt 4.8.

See also QPoint::operator*=().

static QPoint QtCore.QPoint.operator+ ( QPoint  p1,
QPoint  p2 
)
static

Returns a QPoint object that is the sum of the given points, p1 and p2; each component is added separately.

See also QPoint::operator+=().

static QPoint QtCore.QPoint.operator- ( QPoint  p)
static

This is an overloaded function.

Returns a QPoint object that is formed by changing the sign of both components of the given point.

Equivalent to QPoint(0,0) - point.

static QPoint QtCore.QPoint.operator- ( QPoint  p1,
QPoint  p2 
)
static

Returns a QPoint object that is formed by subtracting p2 from p1; each component is subtracted separately.

See also QPoint::operator-=().

static QPoint QtCore.QPoint.operator/ ( QPoint  p,
double  c 
)
static

Returns the QPoint formed by dividing both components of the given point by the given divisor.

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

See also QPoint::operator/=().

static bool QtCore.QPoint.operator== ( QPoint  p1,
QPoint  p2 
)
static

Returns true if p1 and p2 are equal; otherwise returns false.

Member Data Documentation

SmokeInvocation QtCore.QPoint.interceptor
protected

Property Documentation

bool QtCore.QPoint.IsNull
get

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

int QtCore.QPoint.ManhattanLength
get

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 = 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.

int QtCore.QPoint.Rx
get

Returns a reference to the x coordinate of this point.

Using a reference makes it possible to directly manipulate x. For example:

QPoint p(1, 2);

p.rx()–; // p becomes (0, 2)

See also x() and setX().

int QtCore.QPoint.Ry
get

Returns a reference to the y coordinate of this point.

Using a reference makes it possible to directly manipulate y. For example:

QPoint p(1, 2);

p.ry()++; // p becomes (1, 3)

See also y() and setY().

virtual System.IntPtr QtCore.QPoint.SmokeObject
getset
int QtCore.QPoint.X
getset

Returns the x coordinate of this point.

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

int QtCore.QPoint.Y
getset

Returns the y coordinate of this point.

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