#[repr(C)]pub struct QPoint { /* private fields */ }
Expand description
The QPoint class defines a point in the plane using integer precision.
C++ class: QPoint
.
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.
Implementations§
source§impl QPoint
impl QPoint
sourcepub unsafe fn add_assign(&self, p: impl CastInto<Ref<QPoint>>) -> Ref<QPoint>
pub unsafe fn add_assign(&self, p: impl CastInto<Ref<QPoint>>) -> Ref<QPoint>
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)
.
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-=().
sourcepub unsafe fn copy_from(&self, other: impl CastInto<Ref<QPoint>>) -> Ref<QPoint>
pub unsafe fn copy_from(&self, other: impl CastInto<Ref<QPoint>>) -> Ref<QPoint>
The QPoint class defines a point in the plane using integer precision.
Calls C++ function: QPoint& QPoint::operator=(const QPoint& other)
.
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.
sourcepub unsafe fn div_assign(&self, divisor: c_double) -> Ref<QPoint>
pub unsafe fn div_assign(&self, divisor: c_double) -> Ref<QPoint>
This is an overloaded function.
Calls C++ function: QPoint& QPoint::operator/=(double divisor)
.
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*=().
sourcepub unsafe fn dot_product(
p1: impl CastInto<Ref<QPoint>>,
p2: impl CastInto<Ref<QPoint>>
) -> c_int
pub unsafe fn dot_product( p1: impl CastInto<Ref<QPoint>>, p2: impl CastInto<Ref<QPoint>> ) -> c_int
sourcepub unsafe fn is_null(&self) -> bool
pub unsafe fn is_null(&self) -> bool
Returns true
if both the x and y coordinates are set to 0, otherwise returns false
.
Calls C++ function: bool QPoint::isNull() const
.
Returns true
if both the x and y coordinates are set to 0, otherwise returns false
.
sourcepub unsafe fn manhattan_length(&self) -> c_int
pub unsafe fn manhattan_length(&self) -> c_int
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
.
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.
sourcepub unsafe fn mul(&self, factor: c_double) -> CppBox<QPoint>
pub unsafe fn mul(&self, factor: c_double) -> CppBox<QPoint>
Calls C++ function: QPoint operator*(const QPoint& p, double factor)
.
sourcepub unsafe fn mul_assign_float(&self, factor: c_float) -> Ref<QPoint>
pub unsafe fn mul_assign_float(&self, factor: c_float) -> Ref<QPoint>
Multiplies this point's coordinates by the given factor, and returns a reference to this point.
Calls C++ function: QPoint& QPoint::operator*=(float factor)
.
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/=().
sourcepub unsafe fn mul_assign_double(&self, factor: c_double) -> Ref<QPoint>
pub unsafe fn mul_assign_double(&self, factor: c_double) -> Ref<QPoint>
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)
.
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/=().
sourcepub unsafe fn mul_assign_int(&self, factor: c_int) -> Ref<QPoint>
pub unsafe fn mul_assign_int(&self, factor: c_int) -> Ref<QPoint>
Multiplies this point's coordinates by the given factor, and returns a reference to this point.
Calls C++ function: QPoint& QPoint::operator*=(int factor)
.
Multiplies this point’s coordinates by the given factor, and returns a reference to this point.
See also operator/=().
sourcepub unsafe fn neg(&self) -> CppBox<QPoint>
pub unsafe fn neg(&self) -> CppBox<QPoint>
Calls C++ function: QPoint operator-(const QPoint& p)
.
sourcepub unsafe fn new_0a() -> CppBox<QPoint>
pub unsafe fn new_0a() -> CppBox<QPoint>
Constructs a null point, i.e. with coordinates (0, 0)
Calls C++ function: [constructor] void QPoint::QPoint()
.
Constructs a null point, i.e. with coordinates (0, 0)
See also isNull().
sourcepub unsafe fn new_2a(xpos: c_int, ypos: c_int) -> CppBox<QPoint>
pub unsafe fn new_2a(xpos: c_int, ypos: c_int) -> CppBox<QPoint>
Constructs a point with the given coordinates (xpos, ypos).
Calls C++ function: [constructor] void QPoint::QPoint(int xpos, int ypos)
.
sourcepub unsafe fn new_copy(other: impl CastInto<Ref<QPoint>>) -> CppBox<QPoint>
pub unsafe fn new_copy(other: impl CastInto<Ref<QPoint>>) -> CppBox<QPoint>
The QPoint class defines a point in the plane using integer precision.
Calls C++ function: [constructor] void QPoint::QPoint(const QPoint& other)
.
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.
sourcepub unsafe fn rx(&self) -> *mut c_int
pub unsafe fn rx(&self) -> *mut c_int
Returns a reference to the x coordinate of this point.
Calls C++ function: int& QPoint::rx()
.
sourcepub unsafe fn ry(&self) -> *mut c_int
pub unsafe fn ry(&self) -> *mut c_int
Returns a reference to the y coordinate of this point.
Calls C++ function: int& QPoint::ry()
.
sourcepub unsafe fn set_x(&self, x: c_int)
pub unsafe fn set_x(&self, x: c_int)
Sets the x coordinate of this point to the given x coordinate.
Calls C++ function: void QPoint::setX(int x)
.
sourcepub unsafe fn set_y(&self, y: c_int)
pub unsafe fn set_y(&self, y: c_int)
Sets the y coordinate of this point to the given y coordinate.
Calls C++ function: void QPoint::setY(int y)
.
sourcepub unsafe fn sub_assign(&self, p: impl CastInto<Ref<QPoint>>) -> Ref<QPoint>
pub unsafe fn sub_assign(&self, p: impl CastInto<Ref<QPoint>>) -> Ref<QPoint>
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)
.
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+=().
sourcepub unsafe fn transposed(&self) -> CppBox<QPoint>
Available on cpp_lib_version="5.14.0"
only.
pub unsafe fn transposed(&self) -> CppBox<QPoint>
cpp_lib_version="5.14.0"
only.sourcepub unsafe fn unary_plus(&self) -> CppBox<QPoint>
pub unsafe fn unary_plus(&self) -> CppBox<QPoint>
Calls C++ function: QPoint operator+(const QPoint& p)
.
Trait Implementations§
source§impl CppDeletable for QPoint
impl CppDeletable for QPoint
source§unsafe fn delete(&self)
unsafe fn delete(&self)
The QPoint class defines a point in the plane using integer precision.
Calls C++ function: [destructor] void QPoint::~QPoint()
.
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.
source§impl PartialEq<Ref<QPoint>> for QPoint
impl PartialEq<Ref<QPoint>> for QPoint
source§fn eq(&self, p2: &Ref<QPoint>) -> bool
fn eq(&self, p2: &Ref<QPoint>) -> bool
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
.