pub struct QRect { /* private fields */ }
Expand description
The QRect struct defines a rectangle in the plane using integer precision.
Implementations§
Source§impl QRect
impl QRect
Sourcepub fn adjust(&mut self, dx1: i32, dy1: i32, dx2: i32, dy2: i32)
pub fn adjust(&mut self, dx1: i32, dy1: i32, dx2: i32, dy2: i32)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Sourcepub fn adjusted(&self, dx1: i32, dy1: i32, dx2: i32, dy2: i32) -> QRect
pub fn adjusted(&self, dx1: i32, dy1: i32, dx2: i32, dy2: i32) -> QRect
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of this rectangle.
Sourcepub fn bottom(&self) -> i32
pub fn bottom(&self) -> i32
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.
Sourcepub fn bottom_left(&self) -> QPoint
pub fn bottom_left(&self) -> QPoint
Returns the position of the rectangle’s bottom-left corner.
Note that for historical reasons this function returns QPoint(left(), top() + height() - 1).
Sourcepub fn bottom_right(&self) -> QPoint
pub fn bottom_right(&self) -> QPoint
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).
Sourcepub fn contains(&self, point: &QPoint, proper: bool) -> bool
pub fn contains(&self, point: &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).
Sourcepub fn intersected(&self, rectangle: &QRect) -> QRect
pub fn intersected(&self, rectangle: &QRect) -> QRect
Returns the intersection of this rectangle and the given rectangle. Note that r.intersected(s) is equivalent to r & s.
Sourcepub fn intersects(&self, rectangle: &QRect) -> bool
pub fn intersects(&self, rectangle: &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.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
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()).
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
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.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
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()).
Sourcepub fn left(&self) -> i32
pub fn left(&self) -> i32
Returns the x-coordinate of the rectangle’s left edge. Equivalent to x().
Sourcepub fn margins_added(&self, margins: &QMargins) -> QRect
pub fn margins_added(&self, margins: &QMargins) -> QRect
Returns a rectangle grown by the margins.
Sourcepub fn margins_removed(&self, margins: &QMargins) -> QRect
pub fn margins_removed(&self, margins: &QMargins) -> QRect
Removes the margins from the rectangle, shrinking it.
Sourcepub fn move_bottom(&mut self, y: i32)
pub fn move_bottom(&mut self, y: i32)
Moves the rectangle vertically, leaving the rectangle’s bottom edge at the given y coordinate. The rectangle’s size is unchanged.
Sourcepub fn move_bottom_left(&mut self, position: &QPoint)
pub fn move_bottom_left(&mut self, position: &QPoint)
Moves the rectangle, leaving the bottom-left corner at the given position. The rectangle’s size is unchanged.
Sourcepub fn move_bottom_right(&mut self, position: &QPoint)
pub fn move_bottom_right(&mut self, position: &QPoint)
Moves the rectangle, leaving the bottom-right corner at the given position. The rectangle’s size is unchanged.
Sourcepub fn move_center(&mut self, position: &QPoint)
pub fn move_center(&mut self, position: &QPoint)
Moves the rectangle, leaving the center point at the given position. The rectangle’s size is unchanged.
Sourcepub fn move_left(&mut self, x: i32)
pub fn move_left(&mut self, x: i32)
Moves the rectangle horizontally, leaving the rectangle’s left edge at the given x coordinate. The rectangle’s size is unchanged.
Sourcepub fn move_right(&mut self, x: i32)
pub fn move_right(&mut self, x: i32)
Moves the rectangle horizontally, leaving the rectangle’s right edge at the given x coordinate. The rectangle’s size is unchanged.
Sourcepub fn move_to(&mut self, position: &QPoint)
pub fn move_to(&mut self, position: &QPoint)
Moves the rectangle, leaving the top-left corner at the given position.
Sourcepub fn move_top(&mut self, y: i32)
pub fn move_top(&mut self, y: i32)
Moves the rectangle vertically, leaving the rectangle’s top edge at the given y coordinate. The rectangle’s size is unchanged.
Sourcepub fn move_top_left(&mut self, position: &QPoint)
pub fn move_top_left(&mut self, position: &QPoint)
Moves the rectangle, leaving the top-left corner at the given position. The rectangle’s size is unchanged.
Sourcepub fn move_top_right(&mut self, position: &QPoint)
pub fn move_top_right(&mut self, position: &QPoint)
Moves the rectangle, leaving the top-right corner at the given position. The rectangle’s size is unchanged.
Sourcepub fn normalized(&self) -> QRect
pub fn normalized(&self) -> QRect
Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height.
Sourcepub fn right(&self) -> i32
pub fn right(&self) -> i32
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.
Sourcepub fn set_bottom(&mut self, y: i32)
pub fn set_bottom(&mut self, y: i32)
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.
Sourcepub fn set_bottom_left(&mut self, position: &QPoint)
pub fn set_bottom_left(&mut self, position: &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.
Sourcepub fn set_bottom_right(&mut self, position: &QPoint)
pub fn set_bottom_right(&mut self, position: &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.
Sourcepub fn set_coords(&mut self, x1: i32, y1: i32, x2: i32, y2: i32)
pub fn set_coords(&mut self, x1: i32, y1: i32, x2: i32, y2: i32)
Sets the coordinates of the rectangle’s top-left corner to (x1, y1), and the coordinates of its bottom-right corner to (x2, y2).
Sourcepub fn set_height(&mut self, h: i32)
pub fn set_height(&mut self, h: i32)
Sets the height of the rectangle to the given height. The bottom edge is changed, but not the top one.
Sourcepub fn set_left(&mut self, x: i32)
pub fn set_left(&mut self, x: i32)
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.
Sourcepub fn set_rect(&mut self, x: i32, y: i32, width: i32, height: i32)
pub fn set_rect(&mut self, x: i32, y: i32, width: i32, height: i32)
Sets the coordinates of the rectangle’s top-left corner to (x, y), and its size to the given width and height.
Sourcepub fn set_right(&mut self, x: i32)
pub fn set_right(&mut self, x: i32)
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.
Sourcepub fn set_size(&mut self, size: &QSize)
pub fn set_size(&mut self, size: &QSize)
Sets the size of the rectangle to the given size. The top-left corner is not moved.
Sourcepub fn set_top(&mut self, y: i32)
pub fn set_top(&mut self, y: i32)
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.
Sourcepub fn set_top_left(&mut self, position: &QPoint)
pub fn set_top_left(&mut self, position: &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.
Sourcepub fn set_top_right(&mut self, position: &QPoint)
pub fn set_top_right(&mut self, position: &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.
Sourcepub fn set_width(&mut self, w: i32)
pub fn set_width(&mut self, w: i32)
Sets the width of the rectangle to the given width. The right edge is changed, but not the left one.
Sourcepub fn set_x(&mut self, x: i32)
pub fn set_x(&mut self, x: i32)
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.
Sourcepub fn set_y(&mut self, y: i32)
pub fn set_y(&mut self, y: i32)
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.
Sourcepub fn to_rectf(&self) -> QRectF
pub fn to_rectf(&self) -> QRectF
Returns this rectangle as a rectangle with floating point accuracy. This function was introduced in Qt 6.4.
Sourcepub fn top(&self) -> i32
pub fn top(&self) -> i32
Returns the y-coordinate of the rectangle’s top edge. Equivalent to y().
Sourcepub fn top_right(&self) -> QPoint
pub fn top_right(&self) -> QPoint
Returns the position of the rectangle’s top-right corner.
Note that for historical reasons this function returns QPoint(left() + width() -1, top()).
Sourcepub fn translate(&mut self, offset: &QPoint)
pub fn translate(&mut self, offset: &QPoint)
Moves the rectangle offset.x() along the x axis and offset.y() along the y axis, relative to the current position.
Sourcepub fn translated(&self, offset: &QPoint) -> QRect
pub fn translated(&self, offset: &QPoint) -> QRect
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.
Sourcepub fn transposed(&self) -> QRect
pub fn transposed(&self) -> QRect
Returns a copy of the rectangle that has its width and height exchanged.