pub struct QRectF { /* private fields */ }
Expand description
The QRectF struct defines a rectangle in the plane using floating point precision.
Implementations§
Source§impl QRectF
impl QRectF
Sourcepub fn adjust(&mut self, dx1: f64, dy1: f64, dx2: f64, dy2: f64)
pub fn adjust(&mut self, dx1: f64, dy1: f64, dx2: f64, dy2: f64)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle. All parameters must be finite.
Sourcepub fn adjusted(&self, dx1: f64, dy1: f64, dx2: f64, dy2: f64) -> QRectF
pub fn adjusted(&self, dx1: f64, dy1: f64, dx2: f64, dy2: f64) -> QRectF
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of this rectangle. All parameters must be finite.
Sourcepub fn bottom_left(&self) -> QPointF
pub fn bottom_left(&self) -> QPointF
Returns the position of the rectangle’s bottom-left corner.
Sourcepub fn bottom_right(&self) -> QPointF
pub fn bottom_right(&self) -> QPointF
Returns the position of the rectangle’s bottom-right corner.
Sourcepub fn contains(&self, point: &QPointF) -> bool
pub fn contains(&self, point: &QPointF) -> bool
Returns true if the given point is inside or on the edge of the rectangle; otherwise returns false.
Sourcepub fn intersected(&self, rectangle: &QRectF) -> QRectF
pub fn intersected(&self, rectangle: &QRectF) -> QRectF
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: &QRectF) -> bool
pub fn intersects(&self, rectangle: &QRectF) -> bool
Returns true if this rectangle intersects with the given rectangle (i.e. there is a non-empty area of overlap between them), 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 width() <= 0 or height() <= 0. 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. A null rectangle is also empty, and hence 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 width() > 0 and height() > 0. 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) -> f64
pub fn left(&self) -> f64
Returns the x-coordinate of the rectangle’s left edge. Equivalent to x().
Sourcepub fn margins_added(&self, margins: &QMarginsF) -> QRectF
pub fn margins_added(&self, margins: &QMarginsF) -> QRectF
Returns a rectangle grown by the margins.
Sourcepub fn margins_removed(&self, margins: &QMarginsF) -> QRectF
pub fn margins_removed(&self, margins: &QMarginsF) -> QRectF
Removes the margins from the rectangle, shrinking it.
Sourcepub fn move_bottom(&mut self, y: f64)
pub fn move_bottom(&mut self, y: f64)
Moves the rectangle vertically, leaving the rectangle’s bottom edge at the given finite y coordinate. The rectangle’s size is unchanged.
Sourcepub fn move_bottom_left(&mut self, position: &QPointF)
pub fn move_bottom_left(&mut self, position: &QPointF)
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: &QPointF)
pub fn move_bottom_right(&mut self, position: &QPointF)
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: &QPointF)
pub fn move_center(&mut self, position: &QPointF)
Moves the rectangle, leaving the center point at the given position. The rectangle’s size is unchanged.
Sourcepub fn move_left(&mut self, x: f64)
pub fn move_left(&mut self, x: f64)
Moves the rectangle horizontally, leaving the rectangle’s left edge at the given finite x coordinate. The rectangle’s size is unchanged.
Sourcepub fn move_right(&mut self, x: f64)
pub fn move_right(&mut self, x: f64)
Moves the rectangle horizontally, leaving the rectangle’s right edge at the given finite x coordinate. The rectangle’s size is unchanged.
Sourcepub fn move_to(&mut self, position: &QPointF)
pub fn move_to(&mut self, position: &QPointF)
Moves the rectangle, leaving the top-left corner at the given position.
Sourcepub fn move_top(&mut self, y: f64)
pub fn move_top(&mut self, y: f64)
Moves the rectangle vertically, leaving the rectangle’s top line at the given finite y coordinate. The rectangle’s size is unchanged.
Sourcepub fn move_top_left(&mut self, position: &QPointF)
pub fn move_top_left(&mut self, position: &QPointF)
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: &QPointF)
pub fn move_top_right(&mut self, position: &QPointF)
Moves the rectangle, leaving the top-right corner at the given position. The rectangle’s size is unchanged.
Sourcepub fn normalized(&self) -> QRectF
pub fn normalized(&self) -> QRectF
Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height.
Sourcepub fn set_bottom(&mut self, y: f64)
pub fn set_bottom(&mut self, y: f64)
Sets the bottom edge of the rectangle to the given finite y coordinate. May change the height, but will never change the top edge of the rectangle.
Sourcepub fn set_bottom_left(&mut self, position: &QPointF)
pub fn set_bottom_left(&mut self, position: &QPointF)
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: &QPointF)
pub fn set_bottom_right(&mut self, position: &QPointF)
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: f64, y1: f64, x2: f64, y2: f64)
pub fn set_coords(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)
Sets the coordinates of the rectangle’s top-left corner to (x1, y1), and the coordinates of its bottom-right corner to (x2, y2). All parameters must be finite.
Sourcepub fn set_height(&mut self, h: f64)
pub fn set_height(&mut self, h: f64)
Sets the height of the rectangle to the given finite height. The bottom edge is changed, but not the top one.
Sourcepub fn set_left(&mut self, x: f64)
pub fn set_left(&mut self, x: f64)
Sets the left edge of the rectangle to the given finite x coordinate. May change the width, but will never change the right edge of the rectangle.
Sourcepub fn set_rect(&mut self, x: f64, y: f64, width: f64, height: f64)
pub fn set_rect(&mut self, x: f64, y: f64, width: f64, height: f64)
Sets the coordinates of the rectangle’s top-left corner to (x, y), and its size to the given width and height. All parameters must be finite.
Sourcepub fn set_right(&mut self, x: f64)
pub fn set_right(&mut self, x: f64)
Sets the right edge of the rectangle to the given finite x coordinate. May change the width, but will never change the left edge of the rectangle.
Sourcepub fn set_size(&mut self, size: &QSizeF)
pub fn set_size(&mut self, size: &QSizeF)
Sets the size of the rectangle to the given finite size. The top-left corner is not moved.
Sourcepub fn set_top(&mut self, y: f64)
pub fn set_top(&mut self, y: f64)
Sets the top edge of the rectangle to the given finite y coordinate. May change the height, but will never change the bottom edge of the rectangle.
Sourcepub fn set_top_left(&mut self, position: &QPointF)
pub fn set_top_left(&mut self, position: &QPointF)
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: &QPointF)
pub fn set_top_right(&mut self, position: &QPointF)
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: f64)
pub fn set_width(&mut self, w: f64)
Sets the width of the rectangle to the given finite width. The right edge is changed, but not the left one.
Sourcepub fn set_x(&mut self, x: f64)
pub fn set_x(&mut self, x: f64)
Sets the left edge of the rectangle to the given finite x coordinate. May change the width, but will never change the right edge of the rectangle.
Sourcepub fn set_y(&mut self, y: f64)
pub fn set_y(&mut self, y: f64)
Sets the top edge of the rectangle to the given finite y coordinate. May change the height, but will never change the bottom edge of the rectangle.
Sourcepub fn to_aligned_rect(&self) -> QRect
pub fn to_aligned_rect(&self) -> QRect
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle that completely contains this rectangle.
Sourcepub fn to_rect(&self) -> QRect
pub fn to_rect(&self) -> QRect
Returns a QRect based on the values of this rectangle. Note that the coordinates in the returned rectangle are rounded to the nearest integer.
Sourcepub fn top(&self) -> f64
pub fn top(&self) -> f64
Returns the y-coordinate of the rectangle’s top edge. Equivalent to y().
Sourcepub fn translate(&mut self, offset: &QPointF)
pub fn translate(&mut self, offset: &QPointF)
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: &QPointF) -> QRectF
pub fn translated(&self, offset: &QPointF) -> QRectF
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) -> QRectF
pub fn transposed(&self) -> QRectF
Returns a copy of the rectangle that has its width and height exchanged.