#[repr(C)]pub struct QRectF { /* private fields */ }
Expand description
The QRectF class defines a rectangle in the plane using floating point precision.
C++ class: QRectF
.
The QRectF class defines a rectangle in the plane using floating point precision.
A rectangle is normally expressed as an upper-left corner and a size. The size (width and height) of a QRectF is always equivalent to the mathematical rectangle that forms the basis for its rendering.
A QRectF can be constructed with a set of left, top, width and height coordinates, or from a QPointF and a QSizeF. The following code creates two identical rectangles.
QRectF r1(100.0, 200.1, 11.2, 16.3); QRectF r2(QPointF(100.0, 200.1), QSizeF(11.2, 16.3));
There is also a third constructor creating a QRectF from a QRect, and a corresponding toRect() function that returns a QRect object based on the values of this rectangle (note that the coordinates in the returned rectangle are rounded to the nearest integer).
The QRectF class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of these. QRectF 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 QSizeF. 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 (otherwise false). The QRectF 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 the rectangle's width or height is less than, or equal to, 0. Note that an empty rectangle is not valid: The isValid() function returns true
if both width and height is larger than 0. 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 QRectF is defined in essentially the same way as QRect.
Finally, QRectF objects can be streamed as well as compared.
Implementations§
source§impl QRectF
impl QRectF
sourcepub unsafe fn add_assign(
&self,
margins: impl CastInto<Ref<QMarginsF>>
) -> Ref<QRectF>
pub unsafe fn add_assign( &self, margins: impl CastInto<Ref<QMarginsF>> ) -> Ref<QRectF>
Adds the margins to the rectangle, growing it.
Calls C++ function: QRectF& QRectF::operator+=(const QMarginsF& margins)
.
Adds the margins to the rectangle, growing it.
This function was introduced in Qt 5.3.
See also marginsAdded(), marginsRemoved(), and operator-=().
sourcepub unsafe fn adjust(
&self,
x1: c_double,
y1: c_double,
x2: c_double,
y2: c_double
)
pub unsafe fn adjust( &self, x1: c_double, y1: c_double, x2: c_double, y2: c_double )
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Calls C++ function: void QRectF::adjust(double x1, double y1, double x2, double y2)
.
sourcepub unsafe fn adjusted(
&self,
x1: c_double,
y1: c_double,
x2: c_double,
y2: c_double
) -> CppBox<QRectF>
pub unsafe fn adjusted( &self, x1: c_double, y1: c_double, x2: c_double, y2: c_double ) -> CppBox<QRectF>
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of this rectangle.
Calls C++ function: QRectF QRectF::adjusted(double x1, double y1, double x2, double y2) const
.
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of this rectangle.
See also adjust().
sourcepub unsafe fn bit_and_assign(
&self,
r: impl CastInto<Ref<QRectF>>
) -> Ref<QRectF>
pub unsafe fn bit_and_assign( &self, r: impl CastInto<Ref<QRectF>> ) -> Ref<QRectF>
Intersects this rectangle with the given rectangle.
Calls C++ function: QRectF& QRectF::operator&=(const QRectF& r)
.
Intersects this rectangle with the given rectangle.
See also intersected() and operator|=().
sourcepub unsafe fn bit_or_assign(&self, r: impl CastInto<Ref<QRectF>>) -> Ref<QRectF>
pub unsafe fn bit_or_assign(&self, r: impl CastInto<Ref<QRectF>>) -> Ref<QRectF>
Unites this rectangle with the given rectangle.
Calls C++ function: QRectF& QRectF::operator|=(const QRectF& r)
.
sourcepub unsafe fn bottom(&self) -> c_double
pub unsafe fn bottom(&self) -> c_double
Returns the y-coordinate of the rectangle's bottom edge.
Calls C++ function: double QRectF::bottom() const
.
Returns the y-coordinate of the rectangle’s bottom edge.
See also setBottom(), bottomLeft(), and bottomRight().
sourcepub unsafe fn bottom_left(&self) -> CppBox<QPointF>
pub unsafe fn bottom_left(&self) -> CppBox<QPointF>
Returns the position of the rectangle's bottom-left corner.
Calls C++ function: QPointF QRectF::bottomLeft() const
.
Returns the position of the rectangle’s bottom-left corner.
See also setBottomLeft(), bottom(), and left().
sourcepub unsafe fn bottom_right(&self) -> CppBox<QPointF>
pub unsafe fn bottom_right(&self) -> CppBox<QPointF>
Returns the position of the rectangle's bottom-right corner.
Calls C++ function: QPointF QRectF::bottomRight() const
.
Returns the position of the rectangle’s bottom-right corner.
See also setBottomRight(), bottom(), and right().
sourcepub unsafe fn center(&self) -> CppBox<QPointF>
pub unsafe fn center(&self) -> CppBox<QPointF>
Returns the center point of the rectangle.
Calls C++ function: QPointF QRectF::center() const
.
Returns the center point of the rectangle.
See also moveCenter().
sourcepub unsafe fn contains_q_rect_f(&self, r: impl CastInto<Ref<QRectF>>) -> bool
pub unsafe fn contains_q_rect_f(&self, r: impl CastInto<Ref<QRectF>>) -> bool
This is an overloaded function.
Calls C++ function: bool QRectF::contains(const QRectF& r) const
.
This is an overloaded function.
Returns true
if the given rectangle is inside this rectangle; otherwise returns false
.
sourcepub unsafe fn contains_q_point_f(&self, p: impl CastInto<Ref<QPointF>>) -> bool
pub unsafe fn contains_q_point_f(&self, p: impl CastInto<Ref<QPointF>>) -> bool
Returns true
if the given point is inside or on the edge of the rectangle; otherwise returns false
.
Calls C++ function: bool QRectF::contains(const QPointF& p) const
.
Returns true
if the given point is inside or on the edge of the rectangle; otherwise returns false
.
See also intersects().
sourcepub unsafe fn contains_2_double(&self, x: c_double, y: c_double) -> bool
pub unsafe fn contains_2_double(&self, x: c_double, y: c_double) -> bool
This is an overloaded function.
Calls C++ function: bool QRectF::contains(double x, double y) const
.
This is an overloaded function.
Returns true
if the point (x, y) is inside or on the edge of the rectangle; otherwise returns false
.
sourcepub unsafe fn copy_from(&self, other: impl CastInto<Ref<QRectF>>) -> Ref<QRectF>
pub unsafe fn copy_from(&self, other: impl CastInto<Ref<QRectF>>) -> Ref<QRectF>
The QRectF class defines a rectangle in the plane using floating point precision.
Calls C++ function: QRectF& QRectF::operator=(const QRectF& other)
.
The QRectF class defines a rectangle in the plane using floating point precision.
A rectangle is normally expressed as an upper-left corner and a size. The size (width and height) of a QRectF is always equivalent to the mathematical rectangle that forms the basis for its rendering.
A QRectF can be constructed with a set of left, top, width and height coordinates, or from a QPointF and a QSizeF. The following code creates two identical rectangles.
QRectF r1(100.0, 200.1, 11.2, 16.3); QRectF r2(QPointF(100.0, 200.1), QSizeF(11.2, 16.3));
There is also a third constructor creating a QRectF from a QRect, and a corresponding toRect() function that returns a QRect object based on the values of this rectangle (note that the coordinates in the returned rectangle are rounded to the nearest integer).
The QRectF class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of these. QRectF 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 QSizeF. 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 (otherwise false). The QRectF 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 the rectangle's width or height is less than, or equal to, 0. Note that an empty rectangle is not valid: The isValid() function returns true
if both width and height is larger than 0. 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 QRectF is defined in essentially the same way as QRect.
Finally, QRectF objects can be streamed as well as compared.
sourcepub unsafe fn get_coords(
&self,
x1: *mut c_double,
y1: *mut c_double,
x2: *mut c_double,
y2: *mut c_double
)
pub unsafe fn get_coords( &self, x1: *mut c_double, y1: *mut c_double, x2: *mut c_double, y2: *mut c_double )
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 QRectF::getCoords(double* x1, double* y1, double* x2, double* y2) const
.
sourcepub unsafe fn get_rect(
&self,
x: *mut c_double,
y: *mut c_double,
w: *mut c_double,
h: *mut c_double
)
pub unsafe fn get_rect( &self, x: *mut c_double, y: *mut c_double, w: *mut c_double, h: *mut c_double )
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 QRectF::getRect(double* x, double* y, double* w, double* h) const
.
sourcepub unsafe fn height(&self) -> c_double
pub unsafe fn height(&self) -> c_double
Returns the height of the rectangle.
Calls C++ function: double QRectF::height() const
.
sourcepub unsafe fn intersected(
&self,
other: impl CastInto<Ref<QRectF>>
) -> CppBox<QRectF>
pub unsafe fn intersected( &self, other: impl CastInto<Ref<QRectF>> ) -> CppBox<QRectF>
Returns the intersection of this rectangle and the given rectangle. Note that r.intersected(s)
is equivalent to r & s
.
Calls C++ function: QRectF QRectF::intersected(const QRectF& other) const
.
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&=().
sourcepub unsafe fn intersects(&self, r: impl CastInto<Ref<QRectF>>) -> bool
pub unsafe fn intersects(&self, r: impl CastInto<Ref<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
.
Calls C++ function: bool QRectF::intersects(const QRectF& r) const
.
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
.
The intersection rectangle can be retrieved using the intersected() function.
See also contains().
sourcepub unsafe fn is_empty(&self) -> bool
pub unsafe fn is_empty(&self) -> bool
Returns true
if the rectangle is empty, otherwise returns false
.
Calls C++ function: bool QRectF::isEmpty() const
.
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()).
Use the normalized() function to retrieve a rectangle where the corners are swapped.
See also isNull(), isValid(), and normalized().
sourcepub unsafe fn is_null(&self) -> bool
pub unsafe fn is_null(&self) -> bool
Returns true
if the rectangle is a null rectangle, otherwise returns false
.
Calls C++ function: bool QRectF::isNull() const
.
sourcepub unsafe fn is_valid(&self) -> bool
pub unsafe fn is_valid(&self) -> bool
Returns true
if the rectangle is valid, otherwise returns false
.
Calls C++ function: bool QRectF::isValid() const
.
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()).
See also isNull(), isEmpty(), and normalized().
sourcepub unsafe fn left(&self) -> c_double
pub unsafe fn left(&self) -> c_double
Returns the x-coordinate of the rectangle's left edge. Equivalent to x().
Calls C++ function: double QRectF::left() const
.
Returns the x-coordinate of the rectangle’s left edge. Equivalent to x().
See also setLeft(), topLeft(), and bottomLeft().
sourcepub unsafe fn margins_added(
&self,
margins: impl CastInto<Ref<QMarginsF>>
) -> CppBox<QRectF>
pub unsafe fn margins_added( &self, margins: impl CastInto<Ref<QMarginsF>> ) -> CppBox<QRectF>
Returns a rectangle grown by the margins.
Calls C++ function: QRectF QRectF::marginsAdded(const QMarginsF& margins) const
.
Returns a rectangle grown by the margins.
This function was introduced in Qt 5.3.
See also operator+=(), marginsRemoved(), and operator-=().
sourcepub unsafe fn margins_removed(
&self,
margins: impl CastInto<Ref<QMarginsF>>
) -> CppBox<QRectF>
pub unsafe fn margins_removed( &self, margins: impl CastInto<Ref<QMarginsF>> ) -> CppBox<QRectF>
Removes the margins from the rectangle, shrinking it.
Calls C++ function: QRectF QRectF::marginsRemoved(const QMarginsF& margins) const
.
Removes the margins from the rectangle, shrinking it.
This function was introduced in Qt 5.3.
See also marginsAdded(), operator+=(), and operator-=().
sourcepub unsafe fn move_bottom(&self, pos: c_double)
pub unsafe fn move_bottom(&self, pos: c_double)
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 QRectF::moveBottom(double pos)
.
sourcepub unsafe fn move_bottom_left(&self, p: impl CastInto<Ref<QPointF>>)
pub unsafe fn move_bottom_left(&self, p: impl CastInto<Ref<QPointF>>)
Moves the rectangle, leaving the bottom-left corner at the given position. The rectangle's size is unchanged.
Calls C++ function: void QRectF::moveBottomLeft(const QPointF& p)
.
Moves the rectangle, leaving the bottom-left corner at the given position. The rectangle’s size is unchanged.
See also setBottomLeft(), moveBottom(), and moveLeft().
sourcepub unsafe fn move_bottom_right(&self, p: impl CastInto<Ref<QPointF>>)
pub unsafe fn move_bottom_right(&self, p: impl CastInto<Ref<QPointF>>)
Moves the rectangle, leaving the bottom-right corner at the given position. The rectangle's size is unchanged.
Calls C++ function: void QRectF::moveBottomRight(const QPointF& p)
.
Moves the rectangle, leaving the bottom-right corner at the given position. The rectangle’s size is unchanged.
See also setBottomRight(), moveBottom(), and moveRight().
sourcepub unsafe fn move_center(&self, p: impl CastInto<Ref<QPointF>>)
pub unsafe fn move_center(&self, p: impl CastInto<Ref<QPointF>>)
Moves the rectangle, leaving the center point at the given position. The rectangle's size is unchanged.
Calls C++ function: void QRectF::moveCenter(const QPointF& p)
.
Moves the rectangle, leaving the center point at the given position. The rectangle’s size is unchanged.
See also center().
sourcepub unsafe fn move_left(&self, pos: c_double)
pub unsafe fn move_left(&self, pos: c_double)
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 QRectF::moveLeft(double pos)
.
sourcepub unsafe fn move_right(&self, pos: c_double)
pub unsafe fn move_right(&self, pos: c_double)
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 QRectF::moveRight(double pos)
.
sourcepub unsafe fn move_to_2a(&self, x: c_double, y: c_double)
pub unsafe fn move_to_2a(&self, x: c_double, y: c_double)
Moves the rectangle, leaving the top-left corner at the given position (x, y). The rectangle's size is unchanged.
Calls C++ function: void QRectF::moveTo(double x, double y)
.
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().
sourcepub unsafe fn move_to_1a(&self, p: impl CastInto<Ref<QPointF>>)
pub unsafe fn move_to_1a(&self, p: impl CastInto<Ref<QPointF>>)
This is an overloaded function.
Calls C++ function: void QRectF::moveTo(const QPointF& p)
.
This is an overloaded function.
Moves the rectangle, leaving the top-left corner at the given position.
sourcepub unsafe fn move_top(&self, pos: c_double)
pub unsafe fn move_top(&self, pos: c_double)
Moves the rectangle vertically, leaving the rectangle's top line at the given y coordinate. The rectangle's size is unchanged.
Calls C++ function: void QRectF::moveTop(double pos)
.
Moves the rectangle vertically, leaving the rectangle’s top line at the given y coordinate. The rectangle’s size is unchanged.
See also top(), setTop(), and moveBottom().
sourcepub unsafe fn move_top_left(&self, p: impl CastInto<Ref<QPointF>>)
pub unsafe fn move_top_left(&self, p: impl CastInto<Ref<QPointF>>)
Moves the rectangle, leaving the top-left corner at the given position. The rectangle's size is unchanged.
Calls C++ function: void QRectF::moveTopLeft(const QPointF& p)
.
Moves the rectangle, leaving the top-left corner at the given position. The rectangle’s size is unchanged.
See also setTopLeft(), moveTop(), and moveLeft().
sourcepub unsafe fn move_top_right(&self, p: impl CastInto<Ref<QPointF>>)
pub unsafe fn move_top_right(&self, p: impl CastInto<Ref<QPointF>>)
Moves the rectangle, leaving the top-right corner at the given position. The rectangle's size is unchanged.
Calls C++ function: void QRectF::moveTopRight(const QPointF& p)
.
Moves the rectangle, leaving the top-right corner at the given position. The rectangle’s size is unchanged.
See also setTopRight(), moveTop(), and moveRight().
sourcepub unsafe fn new() -> CppBox<QRectF>
pub unsafe fn new() -> CppBox<QRectF>
Constructs a null rectangle.
Calls C++ function: [constructor] void QRectF::QRectF()
.
Constructs a null rectangle.
See also isNull().
sourcepub unsafe fn from_q_point_f_q_size_f(
topleft: impl CastInto<Ref<QPointF>>,
size: impl CastInto<Ref<QSizeF>>
) -> CppBox<QRectF>
pub unsafe fn from_q_point_f_q_size_f( topleft: impl CastInto<Ref<QPointF>>, size: impl CastInto<Ref<QSizeF>> ) -> CppBox<QRectF>
Constructs a rectangle with the given topLeft corner and the given size.
Calls C++ function: [constructor] void QRectF::QRectF(const QPointF& topleft, const QSizeF& size)
.
Constructs a rectangle with the given topLeft corner and the given size.
See also setTopLeft() and setSize().
sourcepub unsafe fn from_2_q_point_f(
topleft: impl CastInto<Ref<QPointF>>,
bottom_right: impl CastInto<Ref<QPointF>>
) -> CppBox<QRectF>
pub unsafe fn from_2_q_point_f( topleft: impl CastInto<Ref<QPointF>>, bottom_right: impl CastInto<Ref<QPointF>> ) -> CppBox<QRectF>
Constructs a rectangle with the given topLeft and bottomRight corners.
Calls C++ function: [constructor] void QRectF::QRectF(const QPointF& topleft, const QPointF& bottomRight)
.
Constructs a rectangle with the given topLeft and bottomRight corners.
This function was introduced in Qt 4.3.
See also setTopLeft() and setBottomRight().
sourcepub unsafe fn from_4_double(
left: c_double,
top: c_double,
width: c_double,
height: c_double
) -> CppBox<QRectF>
pub unsafe fn from_4_double( left: c_double, top: c_double, width: c_double, height: c_double ) -> CppBox<QRectF>
Constructs a rectangle with (x, y) as its top-left corner and the given width and height.
Calls C++ function: [constructor] void QRectF::QRectF(double left, double top, double width, double height)
.
Constructs a rectangle with (x, y) as its top-left corner and the given width and height.
See also setRect().
sourcepub unsafe fn new_copy(other: impl CastInto<Ref<QRectF>>) -> CppBox<QRectF>
pub unsafe fn new_copy(other: impl CastInto<Ref<QRectF>>) -> CppBox<QRectF>
The QRectF class defines a rectangle in the plane using floating point precision.
Calls C++ function: [constructor] void QRectF::QRectF(const QRectF& other)
.
The QRectF class defines a rectangle in the plane using floating point precision.
A rectangle is normally expressed as an upper-left corner and a size. The size (width and height) of a QRectF is always equivalent to the mathematical rectangle that forms the basis for its rendering.
A QRectF can be constructed with a set of left, top, width and height coordinates, or from a QPointF and a QSizeF. The following code creates two identical rectangles.
QRectF r1(100.0, 200.1, 11.2, 16.3); QRectF r2(QPointF(100.0, 200.1), QSizeF(11.2, 16.3));
There is also a third constructor creating a QRectF from a QRect, and a corresponding toRect() function that returns a QRect object based on the values of this rectangle (note that the coordinates in the returned rectangle are rounded to the nearest integer).
The QRectF class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of these. QRectF 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 QSizeF. 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 (otherwise false). The QRectF 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 the rectangle's width or height is less than, or equal to, 0. Note that an empty rectangle is not valid: The isValid() function returns true
if both width and height is larger than 0. 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 QRectF is defined in essentially the same way as QRect.
Finally, QRectF objects can be streamed as well as compared.
sourcepub unsafe fn normalized(&self) -> CppBox<QRectF>
pub unsafe fn normalized(&self) -> CppBox<QRectF>
Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height.
Calls C++ function: QRectF QRectF::normalized() const
.
sourcepub unsafe fn right(&self) -> c_double
pub unsafe fn right(&self) -> c_double
Returns the x-coordinate of the rectangle's right edge.
Calls C++ function: double QRectF::right() const
.
Returns the x-coordinate of the rectangle’s right edge.
See also setRight(), topRight(), and bottomRight().
sourcepub unsafe fn set_bottom(&self, pos: c_double)
pub unsafe fn set_bottom(&self, pos: c_double)
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 QRectF::setBottom(double pos)
.
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().
sourcepub unsafe fn set_bottom_left(&self, p: impl CastInto<Ref<QPointF>>)
pub unsafe fn set_bottom_left(&self, p: impl CastInto<Ref<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.
Calls C++ function: void QRectF::setBottomLeft(const QPointF& p)
.
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().
sourcepub unsafe fn set_bottom_right(&self, p: impl CastInto<Ref<QPointF>>)
pub unsafe fn set_bottom_right(&self, p: impl CastInto<Ref<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.
Calls C++ function: void QRectF::setBottomRight(const QPointF& p)
.
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().
sourcepub unsafe fn set_coords(
&self,
x1: c_double,
y1: c_double,
x2: c_double,
y2: c_double
)
pub unsafe fn set_coords( &self, x1: c_double, y1: c_double, x2: c_double, y2: c_double )
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 QRectF::setCoords(double x1, double y1, double x2, double y2)
.
sourcepub unsafe fn set_height(&self, h: c_double)
pub unsafe fn set_height(&self, h: c_double)
Sets the height of the rectangle to the given height. The bottom edge is changed, but not the top one.
Calls C++ function: void QRectF::setHeight(double h)
.
sourcepub unsafe fn set_left(&self, pos: c_double)
pub unsafe fn set_left(&self, pos: c_double)
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 QRectF::setLeft(double pos)
.
sourcepub unsafe fn set_rect(
&self,
x: c_double,
y: c_double,
w: c_double,
h: c_double
)
pub unsafe fn set_rect( &self, x: c_double, y: c_double, w: c_double, h: c_double )
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 QRectF::setRect(double x, double y, double w, double h)
.
sourcepub unsafe fn set_right(&self, pos: c_double)
pub unsafe fn set_right(&self, pos: c_double)
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 QRectF::setRight(double pos)
.
sourcepub unsafe fn set_size(&self, s: impl CastInto<Ref<QSizeF>>)
pub unsafe fn set_size(&self, s: impl CastInto<Ref<QSizeF>>)
Sets the size of the rectangle to the given size. The top-left corner is not moved.
Calls C++ function: void QRectF::setSize(const QSizeF& s)
.
sourcepub unsafe fn set_top(&self, pos: c_double)
pub unsafe fn set_top(&self, pos: c_double)
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 QRectF::setTop(double pos)
.
sourcepub unsafe fn set_top_left(&self, p: impl CastInto<Ref<QPointF>>)
pub unsafe fn set_top_left(&self, p: impl CastInto<Ref<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.
Calls C++ function: void QRectF::setTopLeft(const QPointF& p)
.
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().
sourcepub unsafe fn set_top_right(&self, p: impl CastInto<Ref<QPointF>>)
pub unsafe fn set_top_right(&self, p: impl CastInto<Ref<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.
Calls C++ function: void QRectF::setTopRight(const QPointF& p)
.
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().
sourcepub unsafe fn set_width(&self, w: c_double)
pub unsafe fn set_width(&self, w: c_double)
Sets the width of the rectangle to the given width. The right edge is changed, but not the left one.
Calls C++ function: void QRectF::setWidth(double w)
.
sourcepub unsafe fn set_x(&self, pos: c_double)
pub unsafe fn set_x(&self, pos: c_double)
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 QRectF::setX(double pos)
.
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().
sourcepub unsafe fn set_y(&self, pos: c_double)
pub unsafe fn set_y(&self, pos: c_double)
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 QRectF::setY(double pos)
.
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().
sourcepub unsafe fn size(&self) -> CppBox<QSizeF>
pub unsafe fn size(&self) -> CppBox<QSizeF>
Returns the size of the rectangle.
Calls C++ function: QSizeF QRectF::size() const
.
sourcepub unsafe fn sub_assign(
&self,
margins: impl CastInto<Ref<QMarginsF>>
) -> Ref<QRectF>
pub unsafe fn sub_assign( &self, margins: impl CastInto<Ref<QMarginsF>> ) -> Ref<QRectF>
Returns a rectangle shrunk by the margins.
Calls C++ function: QRectF& QRectF::operator-=(const QMarginsF& margins)
.
Returns a rectangle shrunk by the margins.
This function was introduced in Qt 5.3.
See also marginsRemoved(), operator+=(), and marginsAdded().
sourcepub unsafe fn to_aligned_rect(&self) -> CppBox<QRect>
pub unsafe fn to_aligned_rect(&self) -> CppBox<QRect>
Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle that completely contains this rectangle.
Calls C++ function: QRect QRectF::toAlignedRect() const
.
sourcepub unsafe fn to_rect(&self) -> CppBox<QRect>
pub unsafe fn to_rect(&self) -> CppBox<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.
Calls C++ function: QRect QRectF::toRect() const
.
Returns a QRect based on the values of this rectangle. Note that the coordinates in the returned rectangle are rounded to the nearest integer.
See also QRectF() and toAlignedRect().
sourcepub unsafe fn top_left(&self) -> CppBox<QPointF>
pub unsafe fn top_left(&self) -> CppBox<QPointF>
Returns the position of the rectangle's top-left corner.
Calls C++ function: QPointF QRectF::topLeft() const
.
Returns the position of the rectangle’s top-left corner.
See also setTopLeft(), top(), and left().
sourcepub unsafe fn top_right(&self) -> CppBox<QPointF>
pub unsafe fn top_right(&self) -> CppBox<QPointF>
Returns the position of the rectangle's top-right corner.
Calls C++ function: QPointF QRectF::topRight() const
.
Returns the position of the rectangle’s top-right corner.
See also setTopRight(), top(), and right().
sourcepub unsafe fn translate_2a(&self, dx: c_double, dy: c_double)
pub unsafe fn translate_2a(&self, dx: c_double, dy: c_double)
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 downwards.
Calls C++ function: void QRectF::translate(double dx, double dy)
.
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 downwards.
See also moveTopLeft(), moveTo(), and translated().
sourcepub unsafe fn translate_1a(&self, p: impl CastInto<Ref<QPointF>>)
pub unsafe fn translate_1a(&self, p: impl CastInto<Ref<QPointF>>)
This is an overloaded function.
Calls C++ function: void QRectF::translate(const QPointF& p)
.
sourcepub unsafe fn translated_2a(&self, dx: c_double, dy: c_double) -> CppBox<QRectF>
pub unsafe fn translated_2a(&self, dx: c_double, dy: c_double) -> CppBox<QRectF>
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: QRectF QRectF::translated(double dx, double dy) const
.
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().
sourcepub unsafe fn translated_1a(
&self,
p: impl CastInto<Ref<QPointF>>
) -> CppBox<QRectF>
pub unsafe fn translated_1a( &self, p: impl CastInto<Ref<QPointF>> ) -> CppBox<QRectF>
This is an overloaded function.
Calls C++ function: QRectF QRectF::translated(const QPointF& p) const
.
sourcepub unsafe fn transposed(&self) -> CppBox<QRectF>
pub unsafe fn transposed(&self) -> CppBox<QRectF>
Returns a copy of the rectangle that has its width and height exchanged:
Calls C++ function: QRectF QRectF::transposed() const
.
Returns a copy of the rectangle that has its width and height exchanged:
QRectF r = {1.5, 5.1, 4.2, 2.4}; r = r.transposed(); // r == {1.5, 5.1, 2.4, 4.2}
This function was introduced in Qt 5.7.
See also QSizeF::transposed().
sourcepub unsafe fn united(&self, other: impl CastInto<Ref<QRectF>>) -> CppBox<QRectF>
pub unsafe fn united(&self, other: impl CastInto<Ref<QRectF>>) -> CppBox<QRectF>
Returns the bounding rectangle of this rectangle and the given rectangle.
Calls C++ function: QRectF QRectF::united(const QRectF& other) const
.
Returns the bounding rectangle of this rectangle and the given rectangle.
This function was introduced in Qt 4.2.
See also intersected().
sourcepub unsafe fn width(&self) -> c_double
pub unsafe fn width(&self) -> c_double
Returns the width of the rectangle.
Calls C++ function: double QRectF::width() const
.
Trait Implementations§
source§impl BitAnd<Ref<QRectF>> for &QRectF
impl BitAnd<Ref<QRectF>> for &QRectF
source§fn bitand(self, r: Ref<QRectF>) -> CppBox<QRectF>
fn bitand(self, r: Ref<QRectF>) -> CppBox<QRectF>
Returns the intersection of this rectangle and the given rectangle. Returns an empty rectangle if there is no intersection.
Calls C++ function: QRectF QRectF::operator&(const QRectF& r) const
.
Returns the intersection of this rectangle and the given rectangle. Returns an empty rectangle if there is no intersection.
See also operator&=() and intersected().
source§impl BitOr<Ref<QRectF>> for &QRectF
impl BitOr<Ref<QRectF>> for &QRectF
source§fn bitor(self, r: Ref<QRectF>) -> CppBox<QRectF>
fn bitor(self, r: Ref<QRectF>) -> CppBox<QRectF>
Returns the bounding rectangle of this rectangle and the given rectangle.
Calls C++ function: QRectF QRectF::operator|(const QRectF& r) const
.
Returns the bounding rectangle of this rectangle and the given rectangle.
See also united() and operator|=().
source§impl CppDeletable for QRectF
impl CppDeletable for QRectF
source§unsafe fn delete(&self)
unsafe fn delete(&self)
The QRectF class defines a rectangle in the plane using floating point precision.
Calls C++ function: [destructor] void QRectF::~QRectF()
.
The QRectF class defines a rectangle in the plane using floating point precision.
A rectangle is normally expressed as an upper-left corner and a size. The size (width and height) of a QRectF is always equivalent to the mathematical rectangle that forms the basis for its rendering.
A QRectF can be constructed with a set of left, top, width and height coordinates, or from a QPointF and a QSizeF. The following code creates two identical rectangles.
QRectF r1(100.0, 200.1, 11.2, 16.3); QRectF r2(QPointF(100.0, 200.1), QSizeF(11.2, 16.3));
There is also a third constructor creating a QRectF from a QRect, and a corresponding toRect() function that returns a QRect object based on the values of this rectangle (note that the coordinates in the returned rectangle are rounded to the nearest integer).
The QRectF class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of these. QRectF 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 QSizeF. 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 (otherwise false). The QRectF 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 the rectangle's width or height is less than, or equal to, 0. Note that an empty rectangle is not valid: The isValid() function returns true
if both width and height is larger than 0. 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 QRectF is defined in essentially the same way as QRect.
Finally, QRectF objects can be streamed as well as compared.
source§impl PartialEq<Ref<QRectF>> for QRectF
impl PartialEq<Ref<QRectF>> for QRectF
source§fn eq(&self, arg2: &Ref<QRectF>) -> bool
fn eq(&self, arg2: &Ref<QRectF>) -> bool
Returns true
if c1 and c2 are the same Unicode character; otherwise returns false
.
Calls C++ function: bool operator==(const QRectF& arg1, const QRectF& 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
.