Struct qt_core::QRect

source ·
#[repr(C)]
pub struct QRect { /* private fields */ }
Expand description

The QRect class defines a rectangle in the plane using integer precision.

C++ class: QRect.

C++ documentation:

The QRect class defines a rectangle in the plane using integer precision.

A rectangle is normally expressed as an upper-left corner and a size. The size (width and height) of a QRect is always equivalent to the mathematical rectangle that forms the basis for its rendering.

A QRect can be constructed with a set of left, top, width and height integers, or from a QPoint and a QSize. The following code creates two identical rectangles.

QRect r1(100, 200, 11, 16); QRect r2(QPoint(100, 200), QSize(11, 16));

There is a third constructor that creates a QRect using the top-left and bottom-right coordinates, but we recommend that you avoid using it. The rationale is that for historical reasons the values returned by the bottom() and right() functions deviate from the true bottom-right corner of the rectangle.

The QRect class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of these. QRect also provide functions to move the rectangle relative to the various coordinates. In addition there is a moveTo() function that moves the rectangle, leaving its top left corner at the given coordinates. Alternatively, the translate() function moves the rectangle the given offset relative to the current position, and the translated() function returns a translated copy of this rectangle.

The size() function returns the rectange's dimensions as a QSize. The dimensions can also be retrieved separately using the width() and height() functions. To manipulate the dimensions use the setSize(), setWidth() or setHeight() functions. Alternatively, the size can be changed by applying either of the functions setting the rectangle coordinates, for example, setBottom() or setRight().

The contains() function tells whether a given point is inside the rectangle or not, and the intersects() function returns true if this rectangle intersects with a given rectangle. The QRect class also provides the intersected() function which returns the intersection rectangle, and the united() function which returns the rectangle that encloses the given rectangle and this:

The isEmpty() function returns true if left() > right() or top() > bottom(). Note that an empty rectangle is not valid: The isValid() function returns true if left() <= right() and top() <= bottom(). A null rectangle (isNull() == true) on the other hand, has both width and height set to 0.

Note that due to the way QRect and QRectF are defined, an empty QRect is defined in essentially the same way as QRectF.

Finally, QRect objects can be streamed as well as compared.

Implementations§

source§

impl QRect

source

pub unsafe fn add_assign( &self, margins: impl CastInto<Ref<QMargins>> ) -> Ref<QRect>

Adds the margins to the rectangle, growing it.

Calls C++ function: QRect& QRect::operator+=(const QMargins& margins).

C++ documentation:

Adds the margins to the rectangle, growing it.

This function was introduced in Qt 5.1.

See also marginsAdded(), marginsRemoved(), and operator-=().

source

pub unsafe fn adjust(&self, x1: c_int, y1: c_int, x2: c_int, y2: c_int)

Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.

Calls C++ function: void QRect::adjust(int x1, int y1, int x2, int y2).

C++ documentation:

Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.

See also adjusted() and setRect().

source

pub unsafe fn adjusted( &self, x1: c_int, y1: c_int, x2: c_int, y2: c_int ) -> CppBox<QRect>

Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of this rectangle.

Calls C++ function: QRect QRect::adjusted(int x1, int y1, int x2, int y2) const.

C++ documentation:

Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of this rectangle.

See also adjust().

source

pub unsafe fn bit_and_assign(&self, r: impl CastInto<Ref<QRect>>) -> Ref<QRect>

Intersects this rectangle with the given rectangle.

Calls C++ function: QRect& QRect::operator&=(const QRect& r).

C++ documentation:

Intersects this rectangle with the given rectangle.

See also intersected() and operator&().

source

pub unsafe fn bit_or_assign(&self, r: impl CastInto<Ref<QRect>>) -> Ref<QRect>

Unites this rectangle with the given rectangle.

Calls C++ function: QRect& QRect::operator|=(const QRect& r).

C++ documentation:

Unites this rectangle with the given rectangle.

See also united() and operator|().

source

pub unsafe fn bottom(&self) -> c_int

Returns the y-coordinate of the rectangle's bottom edge.

Calls C++ function: int QRect::bottom() const.

C++ documentation:

Returns the y-coordinate of the rectangle’s bottom edge.

Note that for historical reasons this function returns top() + height() - 1; use y() + height() to retrieve the true y-coordinate.

See also setBottom(), bottomLeft(), and bottomRight().

source

pub unsafe fn bottom_left(&self) -> CppBox<QPoint>

Returns the position of the rectangle's bottom-left corner. Note that for historical reasons this function returns QPoint(left(), top() + height() - 1).

Calls C++ function: QPoint QRect::bottomLeft() const.

C++ documentation:

Returns the position of the rectangle’s bottom-left corner. Note that for historical reasons this function returns QPoint(left(), top() + height() - 1).

See also setBottomLeft(), bottom(), and left().

source

pub unsafe fn bottom_right(&self) -> CppBox<QPoint>

Returns the position of the rectangle's bottom-right corner.

Calls C++ function: QPoint QRect::bottomRight() const.

C++ documentation:

Returns the position of the rectangle’s bottom-right corner.

Note that for historical reasons this function returns QPoint(left() + width() -1, top() + height() - 1).

See also setBottomRight(), bottom(), and right().

source

pub unsafe fn center(&self) -> CppBox<QPoint>

Returns the center point of the rectangle.

Calls C++ function: QPoint QRect::center() const.

C++ documentation:

Returns the center point of the rectangle.

See also moveCenter().

source

pub unsafe fn contains_q_rect_bool( &self, r: impl CastInto<Ref<QRect>>, proper: bool ) -> bool

This is an overloaded function.

Calls C++ function: bool QRect::contains(const QRect& r, bool proper = …) const.

C++ documentation:

This is an overloaded function.

Returns true if the given rectangle is inside this rectangle. otherwise returns false. If proper is true, this function only returns true if the rectangle is entirely inside this rectangle (not on the edge).

source

pub unsafe fn contains_q_point_bool( &self, p: impl CastInto<Ref<QPoint>>, proper: bool ) -> bool

Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false. If proper is true, this function only returns true if the given point is inside the rectangle (i.e., not on the edge).

Calls C++ function: bool QRect::contains(const QPoint& p, bool proper = …) const.

C++ documentation:

Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false. If proper is true, this function only returns true if the given point is inside the rectangle (i.e., not on the edge).

See also intersects().

source

pub unsafe fn contains_2_int(&self, x: c_int, y: c_int) -> bool

This is an overloaded function.

Calls C++ function: bool QRect::contains(int x, int y) const.

C++ documentation:

This is an overloaded function.

Returns true if the point (x, y) is inside this rectangle, otherwise returns false.

source

pub unsafe fn contains_2_int_bool( &self, x: c_int, y: c_int, proper: bool ) -> bool

This is an overloaded function.

Calls C++ function: bool QRect::contains(int x, int y, bool proper) const.

C++ documentation:

This is an overloaded function.

Returns true if the point (x, y) is inside or on the edge of the rectangle, otherwise returns false. If proper is true, this function only returns true if the point is entirely inside the rectangle(not on the edge).

source

pub unsafe fn contains_q_rect(&self, r: impl CastInto<Ref<QRect>>) -> bool

This is an overloaded function.

Calls C++ function: bool QRect::contains(const QRect& r) const.

C++ documentation:

This is an overloaded function.

Returns true if the given rectangle is inside this rectangle. otherwise returns false. If proper is true, this function only returns true if the rectangle is entirely inside this rectangle (not on the edge).

source

pub unsafe fn contains_q_point(&self, p: impl CastInto<Ref<QPoint>>) -> bool

Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false. If proper is true, this function only returns true if the given point is inside the rectangle (i.e., not on the edge).

Calls C++ function: bool QRect::contains(const QPoint& p) const.

C++ documentation:

Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false. If proper is true, this function only returns true if the given point is inside the rectangle (i.e., not on the edge).

See also intersects().

source

pub unsafe fn copy_from(&self, other: impl CastInto<Ref<QRect>>) -> Ref<QRect>

The QRect class defines a rectangle in the plane using integer precision.

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

C++ documentation:

The QRect class defines a rectangle in the plane using integer precision.

A rectangle is normally expressed as an upper-left corner and a size. The size (width and height) of a QRect is always equivalent to the mathematical rectangle that forms the basis for its rendering.

A QRect can be constructed with a set of left, top, width and height integers, or from a QPoint and a QSize. The following code creates two identical rectangles.

QRect r1(100, 200, 11, 16); QRect r2(QPoint(100, 200), QSize(11, 16));

There is a third constructor that creates a QRect using the top-left and bottom-right coordinates, but we recommend that you avoid using it. The rationale is that for historical reasons the values returned by the bottom() and right() functions deviate from the true bottom-right corner of the rectangle.

The QRect class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of these. QRect also provide functions to move the rectangle relative to the various coordinates. In addition there is a moveTo() function that moves the rectangle, leaving its top left corner at the given coordinates. Alternatively, the translate() function moves the rectangle the given offset relative to the current position, and the translated() function returns a translated copy of this rectangle.

The size() function returns the rectange's dimensions as a QSize. The dimensions can also be retrieved separately using the width() and height() functions. To manipulate the dimensions use the setSize(), setWidth() or setHeight() functions. Alternatively, the size can be changed by applying either of the functions setting the rectangle coordinates, for example, setBottom() or setRight().

The contains() function tells whether a given point is inside the rectangle or not, and the intersects() function returns true if this rectangle intersects with a given rectangle. The QRect class also provides the intersected() function which returns the intersection rectangle, and the united() function which returns the rectangle that encloses the given rectangle and this:

The isEmpty() function returns true if left() > right() or top() > bottom(). Note that an empty rectangle is not valid: The isValid() function returns true if left() <= right() and top() <= bottom(). A null rectangle (isNull() == true) on the other hand, has both width and height set to 0.

Note that due to the way QRect and QRectF are defined, an empty QRect is defined in essentially the same way as QRectF.

Finally, QRect objects can be streamed as well as compared.

source

pub unsafe fn get_coords( &self, x1: *mut c_int, y1: *mut c_int, x2: *mut c_int, y2: *mut c_int )

Extracts the position of the rectangle's top-left corner to *x1 and *y1, and the position of the bottom-right corner to *x2 and *y2.

Calls C++ function: void QRect::getCoords(int* x1, int* y1, int* x2, int* y2) const.

C++ documentation:

Extracts the position of the rectangle’s top-left corner to *x1 and *y1, and the position of the bottom-right corner to *x2 and *y2.

See also setCoords() and getRect().

source

pub unsafe fn get_rect( &self, x: *mut c_int, y: *mut c_int, w: *mut c_int, h: *mut c_int )

Extracts the position of the rectangle's top-left corner to *x and *y, and its dimensions to *width and *height.

Calls C++ function: void QRect::getRect(int* x, int* y, int* w, int* h) const.

C++ documentation:

Extracts the position of the rectangle’s top-left corner to *x and *y, and its dimensions to *width and *height.

See also setRect() and getCoords().

source

pub unsafe fn height(&self) -> c_int

Returns the height of the rectangle.

Calls C++ function: int QRect::height() const.

C++ documentation:

Returns the height of the rectangle.

See also setHeight(), width(), and size().

source

pub unsafe fn intersected( &self, other: impl CastInto<Ref<QRect>> ) -> CppBox<QRect>

Returns the intersection of this rectangle and the given rectangle. Note that r.intersected(s) is equivalent to r & s.

Calls C++ function: QRect QRect::intersected(const QRect& other) const.

C++ documentation:

Returns the intersection of this rectangle and the given rectangle. Note that r.intersected(s) is equivalent to r & s.

This function was introduced in Qt 4.2.

See also intersects(), united(), and operator&=().

source

pub unsafe fn intersects(&self, r: impl CastInto<Ref<QRect>>) -> bool

Returns true if this rectangle intersects with the given rectangle (i.e., there is at least one pixel that is within both rectangles), otherwise returns false.

Calls C++ function: bool QRect::intersects(const QRect& r) const.

C++ documentation:

Returns true if this rectangle intersects with the given rectangle (i.e., there is at least one pixel that is within both rectangles), otherwise returns false.

The intersection rectangle can be retrieved using the intersected() function.

See also contains().

source

pub unsafe fn is_empty(&self) -> bool

Returns true if the rectangle is empty, otherwise returns false.

Calls C++ function: bool QRect::isEmpty() const.

C++ documentation:

Returns true if the rectangle is empty, otherwise returns false.

An empty rectangle has a left() > right() or top() > bottom(). An empty rectangle is not valid (i.e., isEmpty() == !isValid()).

Use the normalized() function to retrieve a rectangle where the corners are swapped.

See also isNull(), isValid(), and normalized().

source

pub unsafe fn is_null(&self) -> bool

Returns true if the rectangle is a null rectangle, otherwise returns false.

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

C++ documentation:

Returns true if the rectangle is a null rectangle, otherwise returns false.

A null rectangle has both the width and the height set to 0 (i.e., right() == left() - 1 and bottom() == top() - 1). A null rectangle is also empty, and hence is not valid.

See also isEmpty() and isValid().

source

pub unsafe fn is_valid(&self) -> bool

Returns true if the rectangle is valid, otherwise returns false.

Calls C++ function: bool QRect::isValid() const.

C++ documentation:

Returns true if the rectangle is valid, otherwise returns false.

A valid rectangle has a left() <= right() and top() <= bottom(). Note that non-trivial operations like intersections are not defined for invalid rectangles. A valid rectangle is not empty (i.e., isValid() == !isEmpty()).

See also isNull(), isEmpty(), and normalized().

source

pub unsafe fn left(&self) -> c_int

Returns the x-coordinate of the rectangle's left edge. Equivalent to x().

Calls C++ function: int QRect::left() const.

C++ documentation:

Returns the x-coordinate of the rectangle’s left edge. Equivalent to x().

See also setLeft(), topLeft(), and bottomLeft().

source

pub unsafe fn margins_added( &self, margins: impl CastInto<Ref<QMargins>> ) -> CppBox<QRect>

Returns a rectangle grown by the margins.

Calls C++ function: QRect QRect::marginsAdded(const QMargins& margins) const.

C++ documentation:

Returns a rectangle grown by the margins.

This function was introduced in Qt 5.1.

See also operator+=(), marginsRemoved(), and operator-=().

source

pub unsafe fn margins_removed( &self, margins: impl CastInto<Ref<QMargins>> ) -> CppBox<QRect>

Removes the margins from the rectangle, shrinking it.

Calls C++ function: QRect QRect::marginsRemoved(const QMargins& margins) const.

C++ documentation:

Removes the margins from the rectangle, shrinking it.

This function was introduced in Qt 5.1.

See also marginsAdded(), operator+=(), and operator-=().

source

pub unsafe fn move_bottom(&self, pos: c_int)

Moves the rectangle vertically, leaving the rectangle's bottom edge at the given y coordinate. The rectangle's size is unchanged.

Calls C++ function: void QRect::moveBottom(int pos).

C++ documentation:

Moves the rectangle vertically, leaving the rectangle’s bottom edge at the given y coordinate. The rectangle’s size is unchanged.

See also bottom(), setBottom(), and moveTop().

source

pub unsafe fn move_bottom_left(&self, p: impl CastInto<Ref<QPoint>>)

Moves the rectangle, leaving the bottom-left corner at the given position. The rectangle's size is unchanged.

Calls C++ function: void QRect::moveBottomLeft(const QPoint& p).

C++ documentation:

Moves the rectangle, leaving the bottom-left corner at the given position. The rectangle’s size is unchanged.

See also setBottomLeft(), moveBottom(), and moveLeft().

source

pub unsafe fn move_bottom_right(&self, p: impl CastInto<Ref<QPoint>>)

Moves the rectangle, leaving the bottom-right corner at the given position. The rectangle's size is unchanged.

Calls C++ function: void QRect::moveBottomRight(const QPoint& p).

C++ documentation:

Moves the rectangle, leaving the bottom-right corner at the given position. The rectangle’s size is unchanged.

See also setBottomRight(), moveRight(), and moveBottom().

source

pub unsafe fn move_center(&self, p: impl CastInto<Ref<QPoint>>)

Moves the rectangle, leaving the center point at the given position. The rectangle's size is unchanged.

Calls C++ function: void QRect::moveCenter(const QPoint& p).

C++ documentation:

Moves the rectangle, leaving the center point at the given position. The rectangle’s size is unchanged.

See also center().

source

pub unsafe fn move_left(&self, pos: c_int)

Moves the rectangle horizontally, leaving the rectangle's left edge at the given x coordinate. The rectangle's size is unchanged.

Calls C++ function: void QRect::moveLeft(int pos).

C++ documentation:

Moves the rectangle horizontally, leaving the rectangle’s left edge at the given x coordinate. The rectangle’s size is unchanged.

See also left(), setLeft(), and moveRight().

source

pub unsafe fn move_right(&self, pos: c_int)

Moves the rectangle horizontally, leaving the rectangle's right edge at the given x coordinate. The rectangle's size is unchanged.

Calls C++ function: void QRect::moveRight(int pos).

C++ documentation:

Moves the rectangle horizontally, leaving the rectangle’s right edge at the given x coordinate. The rectangle’s size is unchanged.

See also right(), setRight(), and moveLeft().

source

pub unsafe fn move_to_2a(&self, x: c_int, t: c_int)

Moves the rectangle, leaving the top-left corner at the given position (x, y). The rectangle's size is unchanged.

Calls C++ function: void QRect::moveTo(int x, int t).

C++ documentation:

Moves the rectangle, leaving the top-left corner at the given position (x, y). The rectangle’s size is unchanged.

See also translate() and moveTopLeft().

source

pub unsafe fn move_to_1a(&self, p: impl CastInto<Ref<QPoint>>)

Moves the rectangle, leaving the top-left corner at the given position.

Calls C++ function: void QRect::moveTo(const QPoint& p).

C++ documentation:

Moves the rectangle, leaving the top-left corner at the given position.

source

pub unsafe fn move_top(&self, pos: c_int)

Moves the rectangle vertically, leaving the rectangle's top edge at the given y coordinate. The rectangle's size is unchanged.

Calls C++ function: void QRect::moveTop(int pos).

C++ documentation:

Moves the rectangle vertically, leaving the rectangle’s top edge at the given y coordinate. The rectangle’s size is unchanged.

See also top(), setTop(), and moveBottom().

source

pub unsafe fn move_top_left(&self, p: impl CastInto<Ref<QPoint>>)

Moves the rectangle, leaving the top-left corner at the given position. The rectangle's size is unchanged.

Calls C++ function: void QRect::moveTopLeft(const QPoint& p).

C++ documentation:

Moves the rectangle, leaving the top-left corner at the given position. The rectangle’s size is unchanged.

See also setTopLeft(), moveTop(), and moveLeft().

source

pub unsafe fn move_top_right(&self, p: impl CastInto<Ref<QPoint>>)

Moves the rectangle, leaving the top-right corner at the given position. The rectangle's size is unchanged.

Calls C++ function: void QRect::moveTopRight(const QPoint& p).

C++ documentation:

Moves the rectangle, leaving the top-right corner at the given position. The rectangle’s size is unchanged.

See also setTopRight(), moveTop(), and moveRight().

source

pub unsafe fn new() -> CppBox<QRect>

Constructs a null rectangle.

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

C++ documentation:

Constructs a null rectangle.

See also isNull().

source

pub unsafe fn from_2_q_point( topleft: impl CastInto<Ref<QPoint>>, bottomright: impl CastInto<Ref<QPoint>> ) -> CppBox<QRect>

Constructs a rectangle with the given topLeft and bottomRight corners.

Calls C++ function: [constructor] void QRect::QRect(const QPoint& topleft, const QPoint& bottomright).

C++ documentation:

Constructs a rectangle with the given topLeft and bottomRight corners.

See also setTopLeft() and setBottomRight().

source

pub unsafe fn from_q_point_q_size( topleft: impl CastInto<Ref<QPoint>>, size: impl CastInto<Ref<QSize>> ) -> CppBox<QRect>

Constructs a rectangle with the given topLeft corner and the given size.

Calls C++ function: [constructor] void QRect::QRect(const QPoint& topleft, const QSize& size).

C++ documentation:

Constructs a rectangle with the given topLeft corner and the given size.

See also setTopLeft() and setSize().

source

pub unsafe fn from_4_int( left: c_int, top: c_int, width: c_int, height: c_int ) -> CppBox<QRect>

Constructs a rectangle with (x, y) as its top-left corner and the given width and height.

Calls C++ function: [constructor] void QRect::QRect(int left, int top, int width, int height).

C++ documentation:

Constructs a rectangle with (x, y) as its top-left corner and the given width and height.

See also setRect().

source

pub unsafe fn new_copy(other: impl CastInto<Ref<QRect>>) -> CppBox<QRect>

The QRect class defines a rectangle in the plane using integer precision.

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

C++ documentation:

The QRect class defines a rectangle in the plane using integer precision.

A rectangle is normally expressed as an upper-left corner and a size. The size (width and height) of a QRect is always equivalent to the mathematical rectangle that forms the basis for its rendering.

A QRect can be constructed with a set of left, top, width and height integers, or from a QPoint and a QSize. The following code creates two identical rectangles.

QRect r1(100, 200, 11, 16); QRect r2(QPoint(100, 200), QSize(11, 16));

There is a third constructor that creates a QRect using the top-left and bottom-right coordinates, but we recommend that you avoid using it. The rationale is that for historical reasons the values returned by the bottom() and right() functions deviate from the true bottom-right corner of the rectangle.

The QRect class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of these. QRect also provide functions to move the rectangle relative to the various coordinates. In addition there is a moveTo() function that moves the rectangle, leaving its top left corner at the given coordinates. Alternatively, the translate() function moves the rectangle the given offset relative to the current position, and the translated() function returns a translated copy of this rectangle.

The size() function returns the rectange's dimensions as a QSize. The dimensions can also be retrieved separately using the width() and height() functions. To manipulate the dimensions use the setSize(), setWidth() or setHeight() functions. Alternatively, the size can be changed by applying either of the functions setting the rectangle coordinates, for example, setBottom() or setRight().

The contains() function tells whether a given point is inside the rectangle or not, and the intersects() function returns true if this rectangle intersects with a given rectangle. The QRect class also provides the intersected() function which returns the intersection rectangle, and the united() function which returns the rectangle that encloses the given rectangle and this:

The isEmpty() function returns true if left() > right() or top() > bottom(). Note that an empty rectangle is not valid: The isValid() function returns true if left() <= right() and top() <= bottom(). A null rectangle (isNull() == true) on the other hand, has both width and height set to 0.

Note that due to the way QRect and QRectF are defined, an empty QRect is defined in essentially the same way as QRectF.

Finally, QRect objects can be streamed as well as compared.

source

pub unsafe fn normalized(&self) -> CppBox<QRect>

Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height.

Calls C++ function: QRect QRect::normalized() const.

C++ documentation:

Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height.

If width() < 0 the function swaps the left and right corners, and it swaps the top and bottom corners if height() < 0.

See also isValid() and isEmpty().

source

pub unsafe fn right(&self) -> c_int

Returns the x-coordinate of the rectangle's right edge.

Calls C++ function: int QRect::right() const.

C++ documentation:

Returns the x-coordinate of the rectangle’s right edge.

Note that for historical reasons this function returns left() + width() - 1; use x() + width() to retrieve the true x-coordinate.

See also setRight(), topRight(), and bottomRight().

source

pub unsafe fn set_bottom(&self, pos: c_int)

Sets the bottom edge of the rectangle to the given y coordinate. May change the height, but will never change the top edge of the rectangle.

Calls C++ function: void QRect::setBottom(int pos).

C++ documentation:

Sets the bottom edge of the rectangle to the given y coordinate. May change the height, but will never change the top edge of the rectangle.

See also bottom() and moveBottom().

source

pub unsafe fn set_bottom_left(&self, p: impl CastInto<Ref<QPoint>>)

Set the bottom-left corner of the rectangle to the given position. May change the size, but will never change the top-right corner of the rectangle.

Calls C++ function: void QRect::setBottomLeft(const QPoint& p).

C++ documentation:

Set the bottom-left corner of the rectangle to the given position. May change the size, but will never change the top-right corner of the rectangle.

See also bottomLeft() and moveBottomLeft().

source

pub unsafe fn set_bottom_right(&self, p: impl CastInto<Ref<QPoint>>)

Set the bottom-right corner of the rectangle to the given position. May change the size, but will never change the top-left corner of the rectangle.

Calls C++ function: void QRect::setBottomRight(const QPoint& p).

C++ documentation:

Set the bottom-right corner of the rectangle to the given position. May change the size, but will never change the top-left corner of the rectangle.

See also bottomRight() and moveBottomRight().

source

pub unsafe fn set_coords(&self, x1: c_int, y1: c_int, x2: c_int, y2: c_int)

Sets the coordinates of the rectangle's top-left corner to (x1, y1), and the coordinates of its bottom-right corner to (x2, y2).

Calls C++ function: void QRect::setCoords(int x1, int y1, int x2, int y2).

C++ documentation:

Sets the coordinates of the rectangle’s top-left corner to (x1, y1), and the coordinates of its bottom-right corner to (x2, y2).

See also getCoords() and setRect().

source

pub unsafe fn set_height(&self, h: c_int)

Sets the height of the rectangle to the given height. The bottom edge is changed, but not the top one.

Calls C++ function: void QRect::setHeight(int h).

C++ documentation:

Sets the height of the rectangle to the given height. The bottom edge is changed, but not the top one.

See also height() and setSize().

source

pub unsafe fn set_left(&self, pos: c_int)

Sets the left edge of the rectangle to the given x coordinate. May change the width, but will never change the right edge of the rectangle.

Calls C++ function: void QRect::setLeft(int pos).

C++ documentation:

Sets the left edge of the rectangle to the given x coordinate. May change the width, but will never change the right edge of the rectangle.

Equivalent to setX().

See also left() and moveLeft().

source

pub unsafe fn set_rect(&self, x: c_int, y: c_int, w: c_int, h: c_int)

Sets the coordinates of the rectangle's top-left corner to (x, y), and its size to the given width and height.

Calls C++ function: void QRect::setRect(int x, int y, int w, int h).

C++ documentation:

Sets the coordinates of the rectangle’s top-left corner to (x, y), and its size to the given width and height.

See also getRect() and setCoords().

source

pub unsafe fn set_right(&self, pos: c_int)

Sets the right edge of the rectangle to the given x coordinate. May change the width, but will never change the left edge of the rectangle.

Calls C++ function: void QRect::setRight(int pos).

C++ documentation:

Sets the right edge of the rectangle to the given x coordinate. May change the width, but will never change the left edge of the rectangle.

See also right() and moveRight().

source

pub unsafe fn set_size(&self, s: impl CastInto<Ref<QSize>>)

Sets the size of the rectangle to the given size. The top-left corner is not moved.

Calls C++ function: void QRect::setSize(const QSize& s).

C++ documentation:

Sets the size of the rectangle to the given size. The top-left corner is not moved.

See also size(), setWidth(), and setHeight().

source

pub unsafe fn set_top(&self, pos: c_int)

Sets the top edge of the rectangle to the given y coordinate. May change the height, but will never change the bottom edge of the rectangle.

Calls C++ function: void QRect::setTop(int pos).

C++ documentation:

Sets the top edge of the rectangle to the given y coordinate. May change the height, but will never change the bottom edge of the rectangle.

Equivalent to setY().

See also top() and moveTop().

source

pub unsafe fn set_top_left(&self, p: impl CastInto<Ref<QPoint>>)

Set the top-left corner of the rectangle to the given position. May change the size, but will never change the bottom-right corner of the rectangle.

Calls C++ function: void QRect::setTopLeft(const QPoint& p).

C++ documentation:

Set the top-left corner of the rectangle to the given position. May change the size, but will never change the bottom-right corner of the rectangle.

See also topLeft() and moveTopLeft().

source

pub unsafe fn set_top_right(&self, p: impl CastInto<Ref<QPoint>>)

Set the top-right corner of the rectangle to the given position. May change the size, but will never change the bottom-left corner of the rectangle.

Calls C++ function: void QRect::setTopRight(const QPoint& p).

C++ documentation:

Set the top-right corner of the rectangle to the given position. May change the size, but will never change the bottom-left corner of the rectangle.

See also topRight() and moveTopRight().

source

pub unsafe fn set_width(&self, w: c_int)

Sets the width of the rectangle to the given width. The right edge is changed, but not the left one.

Calls C++ function: void QRect::setWidth(int w).

C++ documentation:

Sets the width of the rectangle to the given width. The right edge is changed, but not the left one.

See also width() and setSize().

source

pub unsafe fn set_x(&self, x: c_int)

Sets the left edge of the rectangle to the given x coordinate. May change the width, but will never change the right edge of the rectangle.

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

C++ documentation:

Sets the left edge of the rectangle to the given x coordinate. May change the width, but will never change the right edge of the rectangle.

Equivalent to setLeft().

See also x(), setY(), and setTopLeft().

source

pub unsafe fn set_y(&self, y: c_int)

Sets the top edge of the rectangle to the given y coordinate. May change the height, but will never change the bottom edge of the rectangle.

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

C++ documentation:

Sets the top edge of the rectangle to the given y coordinate. May change the height, but will never change the bottom edge of the rectangle.

Equivalent to setTop().

See also y(), setX(), and setTopLeft().

source

pub unsafe fn size(&self) -> CppBox<QSize>

Returns the size of the rectangle.

Calls C++ function: QSize QRect::size() const.

C++ documentation:

Returns the size of the rectangle.

See also setSize(), width(), and height().

source

pub unsafe fn sub_assign( &self, margins: impl CastInto<Ref<QMargins>> ) -> Ref<QRect>

Returns a rectangle shrunk by the margins.

Calls C++ function: QRect& QRect::operator-=(const QMargins& margins).

C++ documentation:

Returns a rectangle shrunk by the margins.

This function was introduced in Qt 5.1.

See also marginsRemoved(), operator+=(), and marginsAdded().

source

pub unsafe fn top(&self) -> c_int

Returns the y-coordinate of the rectangle's top edge. Equivalent to y().

Calls C++ function: int QRect::top() const.

C++ documentation:

Returns the y-coordinate of the rectangle’s top edge. Equivalent to y().

See also setTop(), topLeft(), and topRight().

source

pub unsafe fn top_left(&self) -> CppBox<QPoint>

Returns the position of the rectangle's top-left corner.

Calls C++ function: QPoint QRect::topLeft() const.

C++ documentation:

Returns the position of the rectangle’s top-left corner.

See also setTopLeft(), top(), and left().

source

pub unsafe fn top_right(&self) -> CppBox<QPoint>

Returns the position of the rectangle's top-right corner.

Calls C++ function: QPoint QRect::topRight() const.

C++ documentation:

Returns the position of the rectangle’s top-right corner.

Note that for historical reasons this function returns QPoint(left() + width() -1, top()).

See also setTopRight(), top(), and right().

source

pub unsafe fn translate_2a(&self, dx: c_int, dy: c_int)

Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position. Positive values move the rectangle to the right and down.

Calls C++ function: void QRect::translate(int dx, int dy).

C++ documentation:

Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position. Positive values move the rectangle to the right and down.

See also moveTopLeft(), moveTo(), and translated().

source

pub unsafe fn translate_1a(&self, p: impl CastInto<Ref<QPoint>>)

This is an overloaded function.

Calls C++ function: void QRect::translate(const QPoint& p).

C++ documentation:

This is an overloaded function.

Moves the rectangle offset.x() along the x axis and offset.y() along the y axis, relative to the current position.

source

pub unsafe fn translated_2a(&self, dx: c_int, dy: c_int) -> CppBox<QRect>

Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis, relative to the current position. Positive values move the rectangle to the right and down.

Calls C++ function: QRect QRect::translated(int dx, int dy) const.

C++ documentation:

Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis, relative to the current position. Positive values move the rectangle to the right and down.

See also translate().

source

pub unsafe fn translated_1a( &self, p: impl CastInto<Ref<QPoint>> ) -> CppBox<QRect>

This is an overloaded function.

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

C++ documentation:

This is an overloaded function.

Returns a copy of the rectangle that is translated offset.x() along the x axis and offset.y() along the y axis, relative to the current position.

source

pub unsafe fn transposed(&self) -> CppBox<QRect>

Returns a copy of the rectangle that has its width and height exchanged:

Calls C++ function: QRect QRect::transposed() const.

C++ documentation:

Returns a copy of the rectangle that has its width and height exchanged:


  QRect r = {15, 51, 42, 24};
  r = r.transposed(); // r == {15, 51, 24, 42}

This function was introduced in Qt 5.7.

See also QSize::transposed().

source

pub unsafe fn united(&self, other: impl CastInto<Ref<QRect>>) -> CppBox<QRect>

Returns the bounding rectangle of this rectangle and the given rectangle.

Calls C++ function: QRect QRect::united(const QRect& other) const.

C++ documentation:

Returns the bounding rectangle of this rectangle and the given rectangle.

This function was introduced in Qt 4.2.

See also intersected().

source

pub unsafe fn width(&self) -> c_int

Returns the width of the rectangle.

Calls C++ function: int QRect::width() const.

C++ documentation:

Returns the width of the rectangle.

See also setWidth(), height(), and size().

source

pub unsafe fn x(&self) -> c_int

Returns the x-coordinate of the rectangle's left edge. Equivalent to left().

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

C++ documentation:

Returns the x-coordinate of the rectangle’s left edge. Equivalent to left().

See also setX(), y(), and topLeft().

source

pub unsafe fn y(&self) -> c_int

Returns the y-coordinate of the rectangle's top edge. Equivalent to top().

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

C++ documentation:

Returns the y-coordinate of the rectangle’s top edge. Equivalent to top().

See also setY(), x(), and topLeft().

Trait Implementations§

source§

impl Add<Ref<QMargins>> for &QRect

source§

fn add(self, margins: Ref<QMargins>) -> CppBox<QRect>

Calls C++ function: QRect operator+(const QRect& rectangle, const QMargins& margins).

§

type Output = CppBox<QRect>

The resulting type after applying the + operator.
source§

impl BitAnd<Ref<QRect>> for &QRect

source§

fn bitand(self, r: Ref<QRect>) -> CppBox<QRect>

Returns the intersection of this rectangle and the given rectangle. Returns an empty rectangle if there is no intersection.

Calls C++ function: QRect QRect::operator&(const QRect& r) const.

C++ documentation:

Returns the intersection of this rectangle and the given rectangle. Returns an empty rectangle if there is no intersection.

See also operator&=() and intersected().

§

type Output = CppBox<QRect>

The resulting type after applying the & operator.
source§

impl BitOr<Ref<QRect>> for &QRect

source§

fn bitor(self, r: Ref<QRect>) -> CppBox<QRect>

Returns the bounding rectangle of this rectangle and the given rectangle.

Calls C++ function: QRect QRect::operator|(const QRect& r) const.

C++ documentation:

Returns the bounding rectangle of this rectangle and the given rectangle.

See also operator|=() and united().

§

type Output = CppBox<QRect>

The resulting type after applying the | operator.
source§

impl CppDeletable for QRect

source§

unsafe fn delete(&self)

The QRect class defines a rectangle in the plane using integer precision.

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

C++ documentation:

The QRect class defines a rectangle in the plane using integer precision.

A rectangle is normally expressed as an upper-left corner and a size. The size (width and height) of a QRect is always equivalent to the mathematical rectangle that forms the basis for its rendering.

A QRect can be constructed with a set of left, top, width and height integers, or from a QPoint and a QSize. The following code creates two identical rectangles.

QRect r1(100, 200, 11, 16); QRect r2(QPoint(100, 200), QSize(11, 16));

There is a third constructor that creates a QRect using the top-left and bottom-right coordinates, but we recommend that you avoid using it. The rationale is that for historical reasons the values returned by the bottom() and right() functions deviate from the true bottom-right corner of the rectangle.

The QRect class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of these. QRect also provide functions to move the rectangle relative to the various coordinates. In addition there is a moveTo() function that moves the rectangle, leaving its top left corner at the given coordinates. Alternatively, the translate() function moves the rectangle the given offset relative to the current position, and the translated() function returns a translated copy of this rectangle.

The size() function returns the rectange's dimensions as a QSize. The dimensions can also be retrieved separately using the width() and height() functions. To manipulate the dimensions use the setSize(), setWidth() or setHeight() functions. Alternatively, the size can be changed by applying either of the functions setting the rectangle coordinates, for example, setBottom() or setRight().

The contains() function tells whether a given point is inside the rectangle or not, and the intersects() function returns true if this rectangle intersects with a given rectangle. The QRect class also provides the intersected() function which returns the intersection rectangle, and the united() function which returns the rectangle that encloses the given rectangle and this:

The isEmpty() function returns true if left() > right() or top() > bottom(). Note that an empty rectangle is not valid: The isValid() function returns true if left() <= right() and top() <= bottom(). A null rectangle (isNull() == true) on the other hand, has both width and height set to 0.

Note that due to the way QRect and QRectF are defined, an empty QRect is defined in essentially the same way as QRectF.

Finally, QRect objects can be streamed as well as compared.

source§

impl PartialEq<Ref<QRect>> for QRect

source§

fn eq(&self, arg2: &Ref<QRect>) -> bool

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

Calls C++ function: bool operator==(const QRect& arg1, const QRect& arg2).

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.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Size for QRect

source§

unsafe fn size(&self) -> usize

Returns the size of the rectangle.

Calls C++ function: QSize QRect::size() const.

C++ documentation:

Returns the size of the rectangle.

See also setSize(), width(), and height().

source§

impl Sub<Ref<QMargins>> for &QRect

source§

fn sub(self, rhs: Ref<QMargins>) -> CppBox<QRect>

Calls C++ function: QRect operator-(const QRect& lhs, const QMargins& rhs).

§

type Output = CppBox<QRect>

The resulting type after applying the - operator.

Auto Trait Implementations§

§

impl RefUnwindSafe for QRect

§

impl Send for QRect

§

impl Sync for QRect

§

impl Unpin for QRect

§

impl UnwindSafe for QRect

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.