[][src]Struct qt_core::QPoint

#[repr(C)]
pub struct QPoint { /* fields omitted */ }

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

C++ class: QPoint.

C++ documentation:

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.

Methods

impl QPoint[src]

pub unsafe fn copy_from(
    &mut self,
    other: impl CastInto<Ref<QPoint>>
) -> MutRef<QPoint>
[src]

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

Calls C++ function: QPoint& QPoint::operator=(const QPoint& other).

C++ documentation:

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.

pub unsafe fn dot_product(
    p1: impl CastInto<Ref<QPoint>>,
    p2: impl CastInto<Ref<QPoint>>
) -> c_int
[src]


  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.

Calls C++ function: static int QPoint::dotProduct(const QPoint& p1, const QPoint& p2).

C++ documentation:

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.

pub unsafe fn is_null(&self) -> bool[src]

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

Calls C++ function: bool QPoint::isNull() const.

C++ documentation:

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

pub unsafe fn manhattan_length(&self) -> c_int[src]

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:

Calls C++ function: int QPoint::manhattanLength() const.

C++ documentation:

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.

pub unsafe fn mul(&self, factor: c_double) -> CppBox<QPoint>[src]

Calls C++ function: QPoint operator*(const QPoint& p, double factor).

pub unsafe fn mul_assign(&mut self, factor: c_double) -> MutRef<QPoint>[src]

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

Calls C++ function: QPoint& QPoint::operator*=(double factor).

C++ documentation:

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


  QPoint p(-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.

See also operator/=().

pub unsafe fn neg(&self) -> CppBox<QPoint>[src]

Calls C++ function: QPoint operator-(const QPoint& p).

pub unsafe fn new_0a() -> CppBox<QPoint>[src]

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

Calls C++ function: [constructor] void QPoint::QPoint().

C++ documentation:

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

See also isNull().

pub unsafe fn new_2a(xpos: c_int, ypos: c_int) -> CppBox<QPoint>[src]

Constructs a point with the given coordinates (xpos, ypos).

Calls C++ function: [constructor] void QPoint::QPoint(int xpos, int ypos).

C++ documentation:

Constructs a point with the given coordinates (xpos, ypos).

See also setX() and setY().

pub unsafe fn new_copy(other: impl CastInto<Ref<QPoint>>) -> CppBox<QPoint>[src]

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

Calls C++ function: [constructor] void QPoint::QPoint(const QPoint& other).

C++ documentation:

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.

pub unsafe fn rx(&mut self) -> MutRef<c_int>[src]

Returns a reference to the x coordinate of this point.

Calls C++ function: int& QPoint::rx().

C++ documentation:

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().

pub unsafe fn ry(&mut self) -> MutRef<c_int>[src]

Returns a reference to the y coordinate of this point.

Calls C++ function: int& QPoint::ry().

C++ documentation:

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().

pub unsafe fn set_x(&mut self, x: c_int)[src]

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

Calls C++ function: void QPoint::setX(int x).

C++ documentation:

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

See also x() and setY().

pub unsafe fn set_y(&mut self, y: c_int)[src]

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

Calls C++ function: void QPoint::setY(int y).

C++ documentation:

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

See also y() and setX().

pub unsafe fn unary_plus(&self) -> CppBox<QPoint>[src]

Calls C++ function: QPoint operator+(const QPoint& p).

pub unsafe fn x(&self) -> c_int[src]

Returns the x coordinate of this point.

Calls C++ function: int QPoint::x() const.

C++ documentation:

Returns the x coordinate of this point.

See also setX() and rx().

pub unsafe fn y(&self) -> c_int[src]

Returns the y coordinate of this point.

Calls C++ function: int QPoint::y() const.

C++ documentation:

Returns the y coordinate of this point.

See also setY() and ry().

Trait Implementations

impl PartialEq<Ref<QPoint>> for QPoint[src]

fn eq(&self, p2: &Ref<QPoint>) -> bool[src]

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

Calls C++ function: bool operator==(const QPoint& p1, const QPoint& p2).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(QChar c1, QChar c2):

Returns true if c1 and c2 are the same Unicode character; otherwise returns false.

impl<'_> Div<f64> for &'_ QPoint[src]

type Output = CppBox<QPoint>

The resulting type after applying the / operator.

fn div(self, c: c_double) -> CppBox<QPoint>[src]

Calls C++ function: QPoint operator/(const QPoint& p, double c).

impl<'_> Sub<Ref<QPoint>> for &'_ QPoint[src]

type Output = CppBox<QPoint>

The resulting type after applying the - operator.

fn sub(self, p2: Ref<QPoint>) -> CppBox<QPoint>[src]

Calls C++ function: QPoint operator-(const QPoint& p1, const QPoint& p2).

impl<'_> Add<Ref<QPoint>> for &'_ QPoint[src]

type Output = CppBox<QPoint>

The resulting type after applying the + operator.

fn add(self, p2: Ref<QPoint>) -> CppBox<QPoint>[src]

Calls C++ function: QPoint operator+(const QPoint& p1, const QPoint& p2).

impl<'_> Mul<f32> for &'_ QPoint[src]

type Output = CppBox<QPoint>

The resulting type after applying the * operator.

fn mul(self, factor: c_float) -> CppBox<QPoint>[src]

Calls C++ function: QPoint operator*(const QPoint& p, float factor).

impl<'_> Mul<i32> for &'_ QPoint[src]

type Output = CppBox<QPoint>

The resulting type after applying the * operator.

fn mul(self, factor: c_int) -> CppBox<QPoint>[src]

Calls C++ function: QPoint operator*(const QPoint& p, int factor).

impl AddAssign<Ref<QPoint>> for QPoint[src]

fn add_assign(&mut self, p: Ref<QPoint>)[src]

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

Calls C++ function: QPoint& QPoint::operator+=(const QPoint& p).

C++ documentation:

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


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

See also operator-=().

impl SubAssign<Ref<QPoint>> for QPoint[src]

fn sub_assign(&mut self, p: Ref<QPoint>)[src]

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

Calls C++ function: QPoint& QPoint::operator-=(const QPoint& p).

C++ documentation:

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


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

See also operator+=().

impl MulAssign<f32> for QPoint[src]

fn mul_assign(&mut self, factor: c_float)[src]

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

Calls C++ function: QPoint& QPoint::operator*=(float factor).

C++ documentation:

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.

See also operator/=().

impl MulAssign<i32> for QPoint[src]

fn mul_assign(&mut self, factor: c_int)[src]

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

Calls C++ function: QPoint& QPoint::operator*=(int factor).

C++ documentation:

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

See also operator/=().

impl DivAssign<f64> for QPoint[src]

fn div_assign(&mut self, divisor: c_double)[src]

This is an overloaded function.

Calls C++ function: QPoint& QPoint::operator/=(double divisor).

C++ documentation:

This is an overloaded function.

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

QPoint p(-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.

See also operator*=().

impl CppDeletable for QPoint[src]

unsafe fn delete(&mut self)[src]

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

Calls C++ function: [destructor] void QPoint::~QPoint().

C++ documentation:

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.

Auto Trait Implementations

impl Send for QPoint

impl Sync for QPoint

impl Unpin for QPoint

impl UnwindSafe for QPoint

impl RefUnwindSafe for QPoint

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]