pub struct Point<'a> { /* private fields */ }
Expand description
Notice these docs are heavy WIP and not very relevent yet
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:
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 QPolygon
Licence
The documentation is an adoption of the original Qt Documentation and provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Implementations
sourceimpl<'a> Point<'a>
impl<'a> Point<'a>
pub fn new() -> Point<'a>
sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Returns true
if both the x and y coordinates are set to 0,
otherwise returns false.
sourcepub fn set_x(&self, x: i32) -> &Self
pub fn set_x(&self, x: i32) -> &Self
Sets the x coordinate of this point to the given x coordinate.
See also: x() setY()
sourcepub fn set_y(&self, y: i32) -> &Self
pub fn set_y(&self, y: i32) -> &Self
Sets the y coordinate of this point to the given y coordinate.
See also: y() setX()
sourcepub fn manhattan_length(&self) -> i32
pub fn manhattan_length(&self) -> i32
Returns the sum of the absolute values of x() and y(), traditionally known as the of the vector from the origin to the point. For example:
This is a useful, and quick to calculate, approximation to the true length:
The tradition of arises because such distances apply to travelers who can only travel on a rectangular grid, like the streets of Manhattan.
sourcepub fn rx(&self) -> i32
pub fn rx(&self) -> i32
Returns a reference to the x coordinate of this point.
Using a reference makes it possible to directly manipulate x. For example:
See also: x() setX()
sourcepub fn ry(&self) -> i32
pub fn ry(&self) -> i32
Returns a reference to the y coordinate of this point.
Using a reference makes it possible to directly manipulate y. For example:
See also: y() setY()
sourcepub fn dot_product<P: PointTrait<'a>>(p1: &P, p2: &P) -> i32
pub fn dot_product<P: PointTrait<'a>>(p1: &P, p2: &P) -> i32
Returns the dot product of p1 and p2.