QRectF Class

QRectF 类使用浮点精度定义平面内的有限矩形。更多

头文件: #include <QRectF>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

该类可等价比较

该类可与QRect 进行等价比较

注意:该类中的所有函数都是可重入的

公共函数

QRectF()
QRectF(const QRect &rectangle)
QRectF(const QPointF &topLeft, const QPointF &bottomRight)
QRectF(const QPointF &topLeft, const QSizeF &size)
QRectF(qreal x, qreal y, qreal width, qreal height)
void adjust(qreal dx1, qreal dy1, qreal dx2, qreal dy2)
QRectF adjusted(qreal dx1, qreal dy1, qreal dx2, qreal dy2) const
qreal bottom() const
QPointF bottomLeft() const
QPointF bottomRight() const
QPointF center() const
bool contains(const QPointF &point) const
bool contains(const QRectF &rectangle) const
bool contains(qreal x, qreal y) const
void getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const
void getRect(qreal *x, qreal *y, qreal *width, qreal *height) const
qreal height() const
QRectF intersected(const QRectF &rectangle) const
bool intersects(const QRectF &rectangle) const
bool isEmpty() const
bool isNull() const
bool isValid() const
qreal left() const
QRectF marginsAdded(const QMarginsF &margins) const
QRectF marginsRemoved(const QMarginsF &margins) const
void moveBottom(qreal y)
void moveBottomLeft(const QPointF &position)
void moveBottomRight(const QPointF &position)
void moveCenter(const QPointF &position)
void moveLeft(qreal x)
void moveRight(qreal x)
void moveTo(qreal x, qreal y)
void moveTo(const QPointF &position)
void moveTop(qreal y)
void moveTopLeft(const QPointF &position)
void moveTopRight(const QPointF &position)
QRectF normalized() const
qreal right() const
void setBottom(qreal y)
void setBottomLeft(const QPointF &position)
void setBottomRight(const QPointF &position)
void setCoords(qreal x1, qreal y1, qreal x2, qreal y2)
void setHeight(qreal height)
void setLeft(qreal x)
void setRect(qreal x, qreal y, qreal width, qreal height)
void setRight(qreal x)
void setSize(const QSizeF &size)
void setTop(qreal y)
void setTopLeft(const QPointF &position)
void setTopRight(const QPointF &position)
void setWidth(qreal width)
void setX(qreal x)
void setY(qreal y)
QSizeF size() const
QRect toAlignedRect() const
CGRect toCGRect() const
(since 6.5) emscripten::val toDOMRect() const
QRect toRect() const
qreal top() const
QPointF topLeft() const
QPointF topRight() const
void translate(qreal dx, qreal dy)
void translate(const QPointF &offset)
QRectF translated(qreal dx, qreal dy) const
QRectF translated(const QPointF &offset) const
QRectF transposed() const
QRectF united(const QRectF &rectangle) const
qreal width() const
qreal x() const
qreal y() const
QRectF operator&(const QRectF &rectangle) const
QRectF &operator&=(const QRectF &rectangle)
QRectF &operator+=(const QMarginsF &margins)
QRectF &operator-=(const QMarginsF &margins)
QRectF operator|(const QRectF &rectangle) const
QRectF &operator|=(const QRectF &rectangle)

静态公共成员

QRectF fromCGRect(CGRect rect)
(since 6.5) QRectF fromDOMRect(emscripten::val domRect)
(since 6.8) bool qFuzzyCompare(const QRectF &lhs, const QRectF &rhs)
(since 6.8) bool qFuzzyIsNull(const QRectF &rect)
bool operator!=(const QRectF &lhs, const QRectF &rhs)
QRectF operator+(const QMarginsF &lhs, const QRectF &rhs)
QRectF operator+(const QRectF &lhs, const QMarginsF &rhs)
QRectF operator-(const QRectF &lhs, const QMarginsF &rhs)
QDataStream &operator<<(QDataStream &stream, const QRectF &rectangle)
bool operator==(const QRectF &lhs, const QRectF &rhs)
QDataStream &operator>>(QDataStream &stream, QRectF &rectangle)

详细描述

矩形通常用左上角和尺寸表示。QRectF 的大小(宽度和高度)总是等同于数学矩形,而数学矩形是矩形渲染的基础。

QRectF 可以用一组左、顶、宽和高坐标来构造,也可以用QPointFQSizeF 来构造。下面的代码创建了两个完全相同的矩形。

QRectF r1(100.0, 200.1, 11.2, 16.3);
QRectF r2(QPointF(100.0, 200.1), QSizeF(11.2, 16.3));

还有第三个构造函数可以从QRect 创建一个 QRectF,以及一个相应的toRect() 函数,该函数会根据该矩形的值返回一个QRect 对象(注意,返回的矩形中的坐标会四舍五入为最接近的整数)。

QRectF 类提供了一系列函数,用于返回各种矩形坐标,并可对这些坐标进行操作。QRectF 还提供了将矩形相对于各种坐标移动的函数。此外,还有一个moveTo() 函数可以移动矩形,使其左上角位于给定坐标处。另外,translate() 函数将矩形移动到相对于当前位置的给定偏移量,而translated() 函数则返回该矩形的平移副本。

size() 函数以QSizeF 的形式返回矩形的尺寸。也可以使用width() 和height() 函数单独获取尺寸。要操作尺寸,请使用setSize(),setWidth() 或setHeight() 函数。另外,也可以通过使用setBottom() 或setRight() 等设置矩形坐标的函数来改变尺寸。

contains() 函数用于判断给定点是否在矩形内部,而intersects() 函数则在该矩形与给定矩形相交时返回true (否则返回 false)。QRectF 类还提供intersected() 函数和united() 函数,前者返回相交矩形,后者返回包围给定矩形和 this:

如果矩形的宽度或高度小于或等于 0,则isEmpty() 函数返回true 。请注意,空矩形无效:如果宽度和高度都大于 0,则isValid() 函数会返回true 。另一方面,空矩形(isNull() ==true)的宽度和高度都设置为 0。

请注意,由于QRect 和 QRectF 的定义方式不同,空 QRectF 的定义方式与QRect 基本相同。

最后,QRectF 对象可以流式传输,也可以比较。

渲染

使用anti-aliased 画图器时,QRectF 的边界线将对称地渲染在数学矩形边界线的两侧。但在使用别名绘制器(默认情况下)时,则会适用其他规则。

当使用一像素宽的画笔渲染时,QRectF 的边界线将被渲染到数学矩形边界线的右侧和下方。

当使用两像素宽的笔进行渲染时,边界线将被数学矩形从中间分开。当笔的像素数为偶数时,会出现这种情况,而使用奇数像素的笔时,备用像素会像单像素的情况一样,呈现在数学矩形的右侧和下方。

逻辑表示一像素宽的笔
两像素宽的笔三像素宽的笔

坐标

QRectF 类提供了一系列函数,用于返回各种矩形坐标并对其进行操作。QRectF 还提供了相对于各种坐标移动矩形的函数。

例如:bottom()、setBottom() 和moveBottom() 函数:bottom() 返回矩形底边的 y 坐标;setBottom() 将矩形底边设置为给定的 y 坐标(可能会改变高度,但绝不会改变矩形顶边);moveBottom() 垂直移动整个矩形,将矩形底边保留在给定的 y 坐标处,其大小保持不变。

此外,还可以使用adjust() 函数为该矩形的坐标添加偏移量,以及使用adjusted() 函数在调整原始矩形的基础上获取一个新矩形。如果宽度和高度中的任何一个为负值,则使用normalized() 函数获取一个四角互换的矩形。

此外,QRectF 还提供了提取矩形左上角和右下角位置的getCoords() 函数,以及提取矩形左上角、宽度和高度的getRect() 函数。使用setCoords() 和setRect() 函数可以一次性操作矩形的坐标和尺寸。

另请参阅 QRectQRegion

成员函数文档

[constexpr noexcept] QRectF::QRectF()

构造一个空矩形。

另请参见 isNull()。

[constexpr noexcept] QRectF::QRectF(const QRect &rectangle)

从给定的QRect rectangle 构建一个 QRectF 矩形。

注: QRect::toRectF() 一样,此函数保留rectanglesize() 角,而不是其bottomRight() 角。

另请参阅 toRect() 和QRect::toRectF()。

[constexpr noexcept] QRectF::QRectF(const QPointF &topLeft, const QPointF &bottomRight)

以给定的topLeftbottomRight 角构建矩形。

另请参阅 setTopLeft() 和setBottomRight()。

[constexpr noexcept] QRectF::QRectF(const QPointF &topLeft, const QSizeF &size)

构造一个矩形,该矩形的角为topLeft ,角值为size

另请参阅 setTopLeft() 和setSize() 。

[constexpr noexcept] QRectF::QRectF(qreal x, qreal y, qreal width, qreal height)

构造一个左上角为 (x,y) 的矩形,并给出widthheight 。所有参数必须是有限的。

另请参见 setRect().

[constexpr noexcept] void QRectF::adjust(qreal dx1, qreal dy1, qreal dx2, qreal dy2)

dx1,dy1,dx2dy2 分别添加到矩形的现有坐标中。所有参数必须是有限的。

另请参见 adjusted() 和setRect()。

[constexpr noexcept] QRectF QRectF::adjusted(qreal dx1, qreal dy1, qreal dx2, qreal dy2) const

返回一个新的矩形,在此矩形的现有坐标上分别添加dx1dy1dx2dy2 。所有参数必须是有限参数。

另请参见 adjust().

[constexpr noexcept] qreal QRectF::bottom() const

返回矩形底边的 y 坐标。

另请参阅 setBottom()、bottomLeft() 和bottomRight()。

[constexpr noexcept] QPointF QRectF::bottomLeft() const

返回矩形左下角的位置。

另请参阅 setBottomLeft()、bottom() 和left()。

[constexpr noexcept] QPointF QRectF::bottomRight() const

返回矩形右下角的位置。

另请参阅 setBottomRight()、bottom() 和right()。

[constexpr noexcept] QPointF QRectF::center() const

返回矩形的中心点。

另请参阅 moveCenter()。

[noexcept] bool QRectF::contains(const QPointF &point) const

如果给定的point 位于矩形内部或边缘,则返回true ;否则返回false

另请参见 intersects()。

[noexcept] bool QRectF::contains(const QRectF &rectangle) const

这是一个重载函数。

如果给定的rectangle 位于该矩形内,则返回true ;否则返回false

[noexcept] bool QRectF::contains(qreal x, qreal y) const

这是一个重载函数。

如果点 (x,y) 位于矩形内部或边缘,则返回true ;否则返回false

[static noexcept] QRectF QRectF::fromCGRect(CGRect rect)

从 CGRectrect 创建QRectF

另请参阅 toCGRect() 。

[static, since 6.5] QRectF QRectF::fromDOMRect(emscripten::val domRect)

将 DOMRect (https://www.w3.org/TR/geometry-1/)domRect 转换为QRectF 。如果提供的参数不是 DOMRect,则行为未定义。

此函数在 Qt 6.5 中引入。

另请参阅 toDOMRect()。

[constexpr] void QRectF::getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const

提取矩形左上角的位置到 *x1 和 *y1 ,提取矩形右下角的位置到 *x2 和 *y2

另请参阅 setCoords() 和getRect()。

[constexpr] void QRectF::getRect(qreal *x, qreal *y, qreal *width, qreal *height) const

提取矩形左上角的位置到 *x 和 *y ,其尺寸到 *width 和 *height

另请参阅 setRect() 和getCoords()。

[constexpr noexcept] qreal QRectF::height() const

返回矩形的高度。

另请参阅 setHeight()、width() 和size()。

[noexcept] QRectF QRectF::intersected(const QRectF &rectangle) const

返回此矩形与给定rectangle 的交集。请注意r.intersected(s) 等同于r & s

另请参阅 intersects()、united() 和operator&=()。

[noexcept] bool QRectF::intersects(const QRectF &rectangle) const

如果该矩形与给定的rectangle 相交(即两者之间存在非空的重叠区域),则返回true ,否则返回false

可以使用intersected() 函数获取相交矩形。

另请参见 contains()。

[constexpr noexcept] bool QRectF::isEmpty() const

如果矩形为空,则返回true ,否则返回false

空矩形的条件是width() <= 0 或height() <= 0。空矩形无效(即 isEmpty() == !isValid() )。

使用normalized() 函数可以获取边角互换的矩形。

另请参阅 isNull()、isValid() 和normalized()。

[constexpr noexcept] bool QRectF::isNull() const

如果矩形为空矩形,则返回true ,否则返回false

空矩形的宽度和高度都设置为 0。 空矩形也是空的,因此无效。

另请参见 isEmpty() 和isValid()。

[constexpr noexcept] bool QRectF::isValid() const

如果矩形有效,则返回true ,否则返回false

有效矩形的width() > 0 和height() > 0。请注意,无效矩形不定义交集等非三维操作。有效矩形不为空(即 isValid() == !isEmpty() )。

另请参见 isNull()、isEmpty() 和normalized()。

[constexpr noexcept] qreal QRectF::left() const

返回矩形左边缘的 x 坐标。等价于x()。

另请参阅 setLeft()、topLeft() 和bottomLeft()。

[constexpr noexcept] QRectF QRectF::marginsAdded(const QMarginsF &margins) const

返回由margins 生长出的矩形。

另请参阅 operator+=(),marginsRemoved() 和operator-=().

[constexpr noexcept] QRectF QRectF::marginsRemoved(const QMarginsF &margins) const

从矩形中删除margins ,缩小矩形。

另请参阅 marginsAdded()、operator+=() 和operator-=()。

[constexpr noexcept] void QRectF::moveBottom(qreal y)

垂直移动矩形,使矩形底边位于给定的有限y 坐标处。矩形的大小保持不变。

另请参阅 bottom()、setBottom() 和moveTop()。

[constexpr noexcept] void QRectF::moveBottomLeft(const QPointF &position)

移动矩形,将左下角保留在给定的position 处。矩形的大小不变。

另请参阅 setBottomLeft()、moveBottom() 和moveLeft()。

[constexpr noexcept] void QRectF::moveBottomRight(const QPointF &position)

移动矩形,将右下角留在给定的position 处。矩形的大小不变。

另请参阅 setBottomRight()、moveBottom() 和moveRight()。

[constexpr noexcept] void QRectF::moveCenter(const QPointF &position)

移动矩形,将中心点留在给定的position 处。矩形的大小不变。

另请参见 center()。

[constexpr noexcept] void QRectF::moveLeft(qreal x)

水平移动矩形,使矩形左边缘位于给定的有限x 坐标处。矩形的大小保持不变。

另请参阅 left()、setLeft() 和moveRight()。

[constexpr noexcept] void QRectF::moveRight(qreal x)

水平移动矩形,使矩形右边缘位于给定的有限x 坐标处。矩形的大小保持不变。

另请参阅 right()、setRight() 和moveLeft()。

[constexpr noexcept] void QRectF::moveTo(qreal x, qreal y)

移动矩形,将左上角保留在指定位置 (x,y)。矩形的大小不变。两个参数都必须是有限的。

另请参见 translate() 和moveTopLeft()。

[constexpr noexcept] void QRectF::moveTo(const QPointF &position)

这是一个重载函数。

移动矩形,将左上角留在给定的position 处。

[constexpr noexcept] void QRectF::moveTop(qreal y)

垂直移动矩形,使矩形顶线位于给定的有限y 坐标处。矩形的大小保持不变。

另请参阅 top()、setTop() 和moveBottom()。

[constexpr noexcept] void QRectF::moveTopLeft(const QPointF &position)

移动矩形,将左上角留在给定的position 处。矩形的大小不变。

另请参阅 setTopLeft()、moveTop() 和moveLeft()。

[constexpr noexcept] void QRectF::moveTopRight(const QPointF &position)

移动矩形,将右上角留在给定的position 处。矩形的大小不变。

另请参阅 setTopRight()、moveTop() 和moveRight()。

[noexcept] QRectF QRectF::normalized() const

返回归一化矩形,即宽度和高度均为非负的矩形。

如果width() < 0,函数会交换左角和右角;如果height() < 0,函数会交换上角和下角。

另请参见 isValid() 和isEmpty()。

返回矩形右边缘的 x 坐标。

另请参阅 setRight()、topRight() 和bottomRight()。

[constexpr noexcept] void QRectF::setBottom(qreal y)

将矩形的底边设置为给定的有限y 坐标。可以改变高度,但不会改变矩形的上边缘。

另请参阅 bottom() 和moveBottom()。

[constexpr noexcept] void QRectF::setBottomLeft(const QPointF &position)

将矩形的左下角设置为给定的position 。可以改变矩形的大小,但不会改变矩形的右上角。

另请参阅 bottomLeft() 和moveBottomLeft()。

[constexpr noexcept] void QRectF::setBottomRight(const QPointF &position)

将矩形的右下角设置为给定的position 。可更改大小,但不会更改矩形的左上角。

另请参阅 bottomRight() 和moveBottomRight()。

[constexpr noexcept] void QRectF::setCoords(qreal x1, qreal y1, qreal x2, qreal y2)

将矩形左上角的坐标设置为 (x1,y1) ,将矩形右下角的坐标设置为 (x2,y2) 。所有参数必须是有限的。

另请参阅 getCoords() 和setRect()。

[constexpr noexcept] void QRectF::setHeight(qreal height)

将矩形的高度设置为给定的有限高度height 。底边会改变,但顶边不会。

另请参阅 height() 和setSize()。

[constexpr noexcept] void QRectF::setLeft(qreal x)

将矩形的左边缘设置为给定的有限x 坐标。可以改变宽度,但不会改变矩形的右边缘。

等同于setX()。

另请参阅 left() 和moveLeft()。

[constexpr noexcept] void QRectF::setRect(qreal x, qreal y, qreal width, qreal height)

将矩形左上角的坐标设置为 (x,y) ,并将其大小设置为给定的widthheight 。所有参数必须是有限的。

另请参阅 getRect() 和setCoords()。

[constexpr noexcept] void QRectF::setRight(qreal x)

将矩形的右边缘设置为给定的有限x 坐标。可以改变宽度,但不会改变矩形的左边缘。

另请参阅 right() 和moveRight()。

[constexpr noexcept] void QRectF::setSize(const QSizeF &size)

将矩形的大小设置为给定的有限size 。左上角不会移动。

另请参阅 size()、setWidth() 和setHeight()。

[constexpr noexcept] void QRectF::setTop(qreal y)

将矩形顶边设置为给定的有限y 坐标。可以改变高度,但不会改变矩形的底边。

等同于setY()。

另请参阅 top() 和moveTop()。

[constexpr noexcept] void QRectF::setTopLeft(const QPointF &position)

将矩形的左上角设置为给定的position 。可以改变矩形的大小,但不会改变矩形的右下角。

另请参阅 topLeft() 和moveTopLeft()。

[constexpr noexcept] void QRectF::setTopRight(const QPointF &position)

将矩形的右上角设置为给定的position 。可更改大小,但不会更改矩形的左下角。

另请参阅 topRight() 和moveTopRight()。

[constexpr noexcept] void QRectF::setWidth(qreal width)

将矩形的宽度设置为给定的有限width 。右边会改变,但左边不会。

另请参阅 width() 和setSize()。

[constexpr noexcept] void QRectF::setX(qreal x)

将矩形的左边缘设置为给定的有限x 坐标。可以改变宽度,但不会改变矩形的右边缘。

等同于setLeft()。

另请参阅 x(),setY() 和setTopLeft()。

[constexpr noexcept] void QRectF::setY(qreal y)

将矩形顶边设置为给定的有限y 坐标。可以改变高度,但不会改变矩形的底边。

等同于setTop()。

另请参阅 y(),setX() 和setTopLeft()。

[constexpr noexcept] QSizeF QRectF::size() const

返回矩形的大小。

另请参阅 setSize()、width() 和height()。

[noexcept] QRect QRectF::toAlignedRect() const

根据此矩形的值返回一个QRect ,此矩形是完全包含此矩形的最小整数矩形。

另请参见 toRect()。

[noexcept] CGRect QRectF::toCGRect() const

QRectF 创建 CGRect。

另请参阅 fromCGRect().

[since 6.5] emscripten::val QRectF::toDOMRect() const

将此对象转换为 DOMRect (https://www.w3.org/TR/geometry-1/)。

此函数在 Qt 6.5 中引入。

另请参阅 fromDOMRect()。

[constexpr noexcept] QRect QRectF::toRect() const

根据此矩形的值返回QRect 。请注意,返回的矩形中的坐标将四舍五入为最接近的整数。

另请参阅 QRectF()、toAlignedRect() 和QRect::toRectF()。

[constexpr noexcept] qreal QRectF::top() const

返回矩形顶边的 y 坐标。等价于y()。

另请参阅 setTop()、topLeft() 和topRight()。

[constexpr noexcept] QPointF QRectF::topLeft() const

返回矩形左上角的位置。

另请参阅 setTopLeft()、top() 和left()。

[constexpr noexcept] QPointF QRectF::topRight() const

返回矩形右上角的位置。

另请参阅 setTopRight()、top() 和right()。

[constexpr noexcept] void QRectF::translate(qreal dx, qreal dy)

相对于当前位置,沿 x 轴移动矩形dx ,沿 y 轴移动矩形dy 。正值会使矩形向右和向下移动。两个参数都必须是有限的。

另请参见 moveTopLeft()、moveTo() 和translated()。

[constexpr noexcept] void QRectF::translate(const QPointF &offset)

这是一个重载函数。

相对于当前位置,沿 x 轴移动矩形offset.x() ,沿 y 轴移动矩形offset.y() 。

[constexpr noexcept] QRectF QRectF::translated(qreal dx, qreal dy) const

返回相对于当前位置沿 x 轴平移dx 和沿 y 轴平移dy 的矩形副本。正值会使矩形向右和向下移动。两个参数都必须是有限的。

另请参见 translate().

[constexpr noexcept] QRectF QRectF::translated(const QPointF &offset) const

这是一个重载函数。

返回相对于当前位置沿 x 轴平移offset.x() 和沿 y 轴平移offset.y() 后的矩形副本。

[constexpr noexcept] QRectF QRectF::transposed() const

返回改变了宽度和高度的矩形副本:

QRectF r = {1.5, 5.1, 4.2, 2.4};
r = r.transposed(); // r == {1.5, 5.1, 2.4, 4.2}

另请参见 QSizeF::transposed()。

[noexcept] QRectF QRectF::united(const QRectF &rectangle) const

返回此矩形与给定rectangle 的边界矩形。

另请参见 intersected()。

[constexpr noexcept] qreal QRectF::width() const

返回矩形的宽度。

另请参阅 setWidth()、height() 和size()。

[constexpr noexcept] qreal QRectF::x() const

返回矩形左边缘的 x 坐标。等价于left()。

另请参阅 setX()、y() 和topLeft()。

[constexpr noexcept] qreal QRectF::y() const

返回矩形顶边的 y 坐标。等价于top()。

另请参阅 setY()、x() 和topLeft()。

[noexcept] QRectF QRectF::operator&(const QRectF &rectangle) const

返回此矩形与给定rectangle 的交集。如果没有交集,则返回空矩形。

另请参阅 operator&=() 和intersected()。

[noexcept] QRectF &QRectF::operator&=(const QRectF &rectangle)

与给定的rectangle 相交。

另请参见 intersected() 和operator&()。

[constexpr noexcept] QRectF &QRectF::operator+=(const QMarginsF &margins)

margins 添加到矩形中,使其增长。

另请参阅 marginsAdded()、marginsRemoved() 和operator-=()。

[constexpr noexcept] QRectF &QRectF::operator-=(const QMarginsF &margins)

返回按margins 缩小的矩形。

另请参见 marginsRemoved()、operator+=() 和marginsAdded()。

[noexcept] QRectF QRectF::operator|(const QRectF &rectangle) const

返回此矩形与给定rectangle 的边界矩形。

另请参阅 united() 和operator|=()。

[noexcept] QRectF &QRectF::operator|=(const QRectF &rectangle)

将此矩形与给定的rectangle 相结合。

另请参阅 united() 和operator|()。

相关非会员

[constexpr noexcept, since 6.8] bool qFuzzyCompare(const QRectF &lhs, const QRectF &rhs)

如果矩形lhs 与矩形rhs 大致相等,则返回true ;否则返回false

此函数在 Qt 6.8 中引入。

[constexpr noexcept, since 6.8] bool qFuzzyIsNull(const QRectF &rect)

如果矩形rect 的宽度和高度都近似等于零,则返回true ;否则返回false

此函数在 Qt 6.8 中引入。

[constexpr noexcept] bool operator!=(const QRectF &lhs, const QRectF &rhs)

如果矩形lhsrhs 足够不同,则返回true ,否则返回false

警告: 此函数不检查严格不等式;而是使用模糊比较来比较矩形的坐标。

[constexpr noexcept] QRectF operator+(const QMarginsF &lhs, const QRectF &rhs)

这是一个重载函数。

返回按rhs 边距增长的lhs 矩形。

[constexpr noexcept] QRectF operator+(const QRectF &lhs, const QMarginsF &rhs)

返回按rhs 边距增长的lhs 矩形。

[constexpr noexcept] QRectF operator-(const QRectF &lhs, const QMarginsF &rhs)

返回按rhs 边距缩小的lhs 矩形。

QDataStream &operator<<(QDataStream &stream, const QRectF &rectangle)

rectangle 写入stream ,并返回对数据流的引用。

另请参阅 序列化 Qt 数据类型

[constexpr noexcept] bool operator==(const QRectF &lhs, const QRectF &rhs)

如果矩形lhsrhs 大致相等,则返回true ,否则返回false

警告: 此函数不检查严格的相等性,而是使用模糊比较来比较矩形的坐标。

另请参见 qFuzzyCompare

QDataStream &operator>>(QDataStream &stream, QRectF &rectangle)

stream 中读取rectangle ,并返回对数据流的引用。

另请参阅 序列化 Qt 数据类型

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.