本页内容

C

Qul::PlatformInterface::RectF Class

class Qul::PlatformInterface::RectF

RectF 类使用浮点精度在平面上定义一个矩形。更多内容...

Header: #include <platforminterface/rect.h>
Since: Qt Quick Ultralite (Platform) 1.5

公共函数

RectF()
RectF(const Qul::PlatformInterface::Rect &rectangle)
RectF(const Qul::PlatformInterface::PointF &topLeft, const Qul::PlatformInterface::PointF &bottomRight)
RectF(const Qul::PlatformInterface::PointF &topLeft, const Qul::PlatformInterface::SizeF &size)
RectF(float x, float y, float width, float height)
void adjust(float dx1, float dy1, float dx2, float dy2)
Qul::PlatformInterface::RectF adjusted(float dx1, float dy1, float dx2, float dy2) const
float bottom() const
Qul::PlatformInterface::PointF bottomLeft() const
Qul::PlatformInterface::PointF bottomRight() const
Qul::PlatformInterface::PointF center() const
bool contains(const Qul::PlatformInterface::PointF &point) const
bool contains(const Qul::PlatformInterface::RectF &rectangle) const
bool contains(float x, float y) const
void getCoords(float *x1, float *y1, float *x2, float *y2) const
void getRect(float *x, float *y, float *width, float *height) const
float height() const
Qul::PlatformInterface::RectF intersected(const Qul::PlatformInterface::RectF &rectangle) const
bool intersects(const Qul::PlatformInterface::RectF &rectangle) const
bool isEmpty() const
bool isNull() const
bool isValid() const
float left() const
void moveBottom(float y)
void moveBottomLeft(const Qul::PlatformInterface::PointF &position)
void moveBottomRight(const Qul::PlatformInterface::PointF &position)
void moveCenter(const Qul::PlatformInterface::PointF &position)
void moveLeft(float x)
void moveRight(float x)
void moveTo(const Qul::PlatformInterface::PointF &position)
void moveTo(float x, float y)
void moveTop(float y)
void moveTopLeft(const Qul::PlatformInterface::PointF &position)
void moveTopRight(const Qul::PlatformInterface::PointF &position)
Qul::PlatformInterface::RectF normalized() const
float right() const
void setBottom(float y)
void setBottomLeft(const Qul::PlatformInterface::PointF &position)
void setBottomRight(const Qul::PlatformInterface::PointF &position)
void setCoords(float x1, float y1, float x2, float y2)
void setHeight(float height)
void setLeft(float x)
void setRect(float x, float y, float width, float height)
void setRight(float x)
void setSize(const Qul::PlatformInterface::SizeF &size)
void setTop(float y)
void setTopLeft(const Qul::PlatformInterface::PointF &position)
void setTopRight(const Qul::PlatformInterface::PointF &position)
void setWidth(float width)
void setX(float x)
void setY(float y)
Qul::PlatformInterface::SizeF size() const
Qul::PlatformInterface::Rect toAlignedRect() const
Qul::PlatformInterface::Rect toRect() const
float top() const
Qul::PlatformInterface::PointF topLeft() const
Qul::PlatformInterface::PointF topRight() const
void translate(const Qul::PlatformInterface::PointF &offset)
void translate(float dx, float dy)
Qul::PlatformInterface::RectF translated(const Qul::PlatformInterface::PointF &offset) const
Qul::PlatformInterface::RectF translated(float dx, float dy) const
Qul::PlatformInterface::RectF transposed() const
Qul::PlatformInterface::RectF united(const Qul::PlatformInterface::RectF &rectangle) const
float width() const
float x() const
float y() const
Qul::PlatformInterface::RectF operator&(const Qul::PlatformInterface::RectF &rectangle) const
Qul::PlatformInterface::RectF &operator&=(const Qul::PlatformInterface::RectF &rectangle)
Qul::PlatformInterface::RectF operator|(const Qul::PlatformInterface::RectF &rectangle) const
Qul::PlatformInterface::RectF &operator|=(const Qul::PlatformInterface::RectF &rectangle)
bool operator!=(const Qul::PlatformInterface::RectF &r1, const Qul::PlatformInterface::RectF &r2)
bool operator==(const Qul::PlatformInterface::RectF &r1, const Qul::PlatformInterface::RectF &r2)

详细说明

矩形通常由左上角坐标和尺寸来表示。RectF 的尺寸(宽度和高度)始终与其渲染所依据的数学矩形相对应。

RectF 可以通过一组左、上、宽和高的坐标来构造,也可以通过PointF 和SizeF 来构造。

此外,还有一个第三个构造函数,可从 Rect 对象创建 RectF;同时还有一个对应的toRect() 函数,该函数根据该矩形的值返回一个 Rect 对象(请注意,返回的矩形中的坐标会被四舍五入到最接近的整数)。

RectF 类提供了一组函数,这些函数可返回各种矩形坐标并支持对其进行操作。RectF 还提供了用于根据各种坐标移动矩形的函数。此外,还有moveTo() 函数,该函数在保持矩形左上角位于给定坐标不变的前提下移动矩形。 此外,translate() 函数可将矩形相对于当前位置移动给定的偏移量,而translated() 函数则返回该矩形的平移副本。

size() 函数将矩形的尺寸作为SizeF 返回。也可以通过width() 和height() 函数分别获取这些尺寸。要操作尺寸,请使用setSize()、setWidth() 或setHeight() 函数。此外,还可以通过调用设置矩形坐标的任一函数来更改尺寸,例如setBottom() 或setRight()。

contains() 函数用于判断给定点是否位于矩形内部,而intersects() 函数若该矩形与给定矩形相交则返回true (否则返回 false)。RectF 类还提供了intersected() 函数,该函数返回相交矩形;以及united() 函数,该函数返回同时包含给定矩形和本矩形的包围矩形:

isEmpty() 函数在矩形的宽度或高度小于或等于 0 时返回true 。请注意,空矩形是不合法的:当宽度和高度均大于 0 时,isValid() 函数返回true 。另一方面,空矩形(isNull() == true)的宽度和高度均设为 0。

请注意,由于 Rect 和 RectF 的定义方式,空的 RectF 实际上与 Rect 的定义方式基本相同。

RectF 对象可以进行比较。

坐标

RectF 类提供了一组函数,这些函数返回各种矩形坐标,并允许对这些坐标进行操作。RectF 还提供了用于相对于各种坐标移动矩形的函数。

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

矩形坐标,可通过调整这些坐标来移动矩形,使其相对于坐标系发生位移。

此外,还可以使用adjust()函数对该矩形的坐标添加偏移量,以及使用adjusted()函数根据对原始矩形的调整获取一个新矩形。如果宽度和高度中的任一值为负,请使用normalized()函数来获取一个角点位置互换的矩形。

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

另请参阅 Rect 。

成员函数文档

RectF::RectF()

构建一个空矩形。

另请参阅 isNull()。

RectF::RectF(const Qul::PlatformInterface::Rect &rectangle)

根据给定的 Rect 对象rectangle 构建一个 RectF 矩形。

另请参阅 toRect()。

RectF::RectF(const Qul::PlatformInterface::PointF &topLeft, const Qul::PlatformInterface::PointF &bottomRight)

根据给定的topLeft 和bottomRight 构建一个矩形。

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

RectF::RectF(const Qul::PlatformInterface::PointF &topLeft, const Qul::PlatformInterface::SizeF &size)

根据给定的topLeft 角和size ,构造一个矩形。

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

RectF::RectF(float x, float y, float width, float height)

构建一个矩形,其左上角坐标为 (x,y),边长分别为width 和height 。

另请参阅 setRect()。

void RectF::adjust(float dx1, float dy1, float dx2, float dy2)

分别将dx1 、dy1 、dx2 和dy2 添加到矩形的现有坐标中。

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

Qul::PlatformInterface::RectF RectF::adjusted(float dx1, float dy1, float dx2, float dy2) const

返回一个新的矩形,该矩形的现有坐标分别增加了dx1 、dy1 、dx2 和dy2 。

另请参阅 adjust()。

float RectF::bottom() const

返回矩形底边的 y 坐标。

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

Qul::PlatformInterface::PointF RectF::bottomLeft() const

返回矩形左下角的位置。

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

Qul::PlatformInterface::PointF RectF::bottomRight() const

返回矩形右下角的位置。

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

Qul::PlatformInterface::PointF RectF::center() const

返回矩形的中心点。

另请参阅 ` moveCenter()`。

bool RectF::contains(const Qul::PlatformInterface::PointF &point) const

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

这是一个重载函数。

另请参阅 intersects()。

bool RectF::contains(const Qul::PlatformInterface::RectF &rectangle) const

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

这是一个重载函数。

bool RectF::contains(float x, float y) const

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

这是一个重载函数。

void RectF::getCoords(float *x1, float *y1, float *x2, float *y2) const

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

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

void RectF::getRect(float *x, float *y, float *width, float *height) const

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

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

float RectF::height() const

返回矩形的高度。

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

Qul::PlatformInterface::RectF RectF::intersected(const Qul::PlatformInterface::RectF &rectangle) const

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

两个相交的矩形,其交集部分被涂黑。

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

bool RectF::intersects(const Qul::PlatformInterface::RectF &rectangle) const

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

可通过intersected() 函数获取交集矩形。

另请参阅 contains()。

bool RectF::isEmpty() const

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

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

使用normalized() 函数可获取一个四角被互换的矩形。

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

bool RectF::isNull() const

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

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

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

bool RectF::isValid() const

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

一个有效的矩形满足width() > 0 且height() > 0。请注意,对于无效的矩形,交集等非平凡操作未被定义。有效的矩形不为空(即 isValid() == !isEmpty())。

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

float RectF::left() const

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

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

void RectF::moveBottom(float y)

将矩形沿垂直方向移动,同时保持矩形底边位于给定的y 坐标处。矩形的大小保持不变。

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

void RectF::moveBottomLeft(const Qul::PlatformInterface::PointF &position)

将矩形移动,使其左下角位于给定的position 上。矩形的大小保持不变。

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

void RectF::moveBottomRight(const Qul::PlatformInterface::PointF &position)

将矩形移动,使其右下角位于给定的position 处。矩形的大小保持不变。

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

void RectF::moveCenter(const Qul::PlatformInterface::PointF &position)

将矩形移动,使其中心点位于给定的position 处。矩形的大小保持不变。

另请参阅 center()。

void RectF::moveLeft(float x)

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

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

void RectF::moveRight(float x)

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

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

void RectF::moveTo(const Qul::PlatformInterface::PointF &position)

将矩形移动,使其左上角位于给定的position 处。

这是一个重载函数。

void RectF::moveTo(float x, float y)

将矩形移动,同时保持其左上角位于给定位置(x ,y )。矩形的大小保持不变。

这是一个重载函数。

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

void RectF::moveTop(float y)

将矩形沿垂直方向移动,同时保持矩形顶边位于给定的y 坐标处。矩形的大小保持不变。

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

void RectF::moveTopLeft(const Qul::PlatformInterface::PointF &position)

将矩形移动,使其左上角位于给定的position 处。矩形的大小保持不变。

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

void RectF::moveTopRight(const Qul::PlatformInterface::PointF &position)

将矩形移动,使其右上角位于给定的position 处。矩形的大小保持不变。

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

Qul::PlatformInterface::RectF RectF::normalized() const

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

如果 `width()` < 0,该函数将交换左角和右角的位置;如果 `height()` < 0,则交换顶角和底角的位置。

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

返回矩形右边的 x 坐标。

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

void RectF::setBottom(float y)

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

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

void RectF::setBottomLeft(const Qul::PlatformInterface::PointF &position)

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

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

void RectF::setBottomRight(const Qul::PlatformInterface::PointF &position)

将矩形的右下角设置为给定的position 。可能会改变尺寸,但绝不会改变矩形的左上角。

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

void RectF::setCoords(float x1, float y1, float x2, float y2)

将矩形左上角的坐标设置为 (x1,y1),将其右下角的坐标设置为 (x2,y2)。

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

void RectF::setHeight(float height)

将矩形的高度设置为给定的height 。底部边会发生变化,但顶部边保持不变。

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

void RectF::setLeft(float x)

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

等同于setX()。

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

void RectF::setRect(float x, float y, float width, float height)

将矩形左上角的坐标设置为 (x,y),并将矩形大小设置为给定的width 和height 。

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

void RectF::setRight(float x)

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

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

void RectF::setSize(const Qul::PlatformInterface::SizeF &size)

将矩形的大小设置为给定的size 。左上角位置保持不变。

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

void RectF::setTop(float y)

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

等同于setY()。

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

void RectF::setTopLeft(const Qul::PlatformInterface::PointF &position)

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

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

void RectF::setTopRight(const Qul::PlatformInterface::PointF &position)

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

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

void RectF::setWidth(float width)

将矩形的宽度设置为给定的width 。右边缘会发生变化,但左边缘保持不变。

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

void RectF::setX(float x)

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

等同于setLeft()。

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

void RectF::setY(float y)

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

等同于setTop()。

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

Qul::PlatformInterface::SizeF RectF::size() const

返回矩形的大小。

另请参阅 setSize()、width(),以及height()。

Qul::PlatformInterface::Rect RectF::toAlignedRect() const

根据该矩形的值返回一个 Rect 对象,该 Rect 对象表示能够完全包含该矩形且尺寸最小的整数矩形。

另请参阅 toRect()。

Qul::PlatformInterface::Rect RectF::toRect() const

根据该矩形的值返回一个 Rect 对象。请注意,返回的矩形中的坐标会四舍五入到最接近的整数。

另请参阅 RectF() 和toAlignedRect()。

float RectF::top() const

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

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

Qul::PlatformInterface::PointF RectF::topLeft() const

返回矩形左上角的位置。

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

Qul::PlatformInterface::PointF RectF::topRight() const

返回矩形右上角的位置。

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

void RectF::translate(const Qul::PlatformInterface::PointF &offset)

将矩形offset.x()沿x轴移动,并沿y轴offset.y()移动,以当前位置为基准。

这是一个重载函数。

void RectF::translate(float dx, float dy)

将矩形沿 x 轴移动dx ,沿 y 轴移动dy ,以当前位置为基准。正值会使矩形向右和向下移动。

这是一个重载函数。

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

Qul::PlatformInterface::RectF RectF::translated(const Qul::PlatformInterface::PointF &offset) const

返回一个矩形的副本,该矩形相对于当前位置沿 x 轴平移了offset 。x(),沿 y 轴平移了offset 。y()。

这是一个重载函数。

Qul::PlatformInterface::RectF RectF::translated(float dx, float dy) const

返回一个矩形的副本,该矩形相对于当前位置沿 x 轴平移了dx ,沿 y 轴平移了dy 。正值会将矩形向右和向下移动。

这是一个重载函数。

另请参阅 translate()。

Qul::PlatformInterface::RectF RectF::transposed() const

返回一个矩形的副本,该副本的宽度和高度已被互换。

另请参阅 ` SizeF::transposed()`。

Qul::PlatformInterface::RectF RectF::united(const Qul::PlatformInterface::RectF &rectangle) const

返回该矩形与给定的rectangle 的包围矩形。

一个较大的外围矩形内有两个矩形。

另请参阅 intersected()。

float RectF::width() const

返回矩形的宽度。

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

float RectF::x() const

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

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

float RectF::y() const

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

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

Qul::PlatformInterface::RectF RectF::operator&(const Qul::PlatformInterface::RectF &rectangle) const

返回该矩形与给定的rectangle 的交集。如果不存在交集,则返回一个空矩形。

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

Qul::PlatformInterface::RectF &RectF::operator&=(const Qul::PlatformInterface::RectF &rectangle)

求该矩形与给定的rectangle 的交集。

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

Qul::PlatformInterface::RectF RectF::operator|(const Qul::PlatformInterface::RectF &rectangle) const

返回该矩形与给定的rectangle 的包围矩形。

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

Qul::PlatformInterface::RectF &RectF::operator|=(const Qul::PlatformInterface::RectF &rectangle)

将此矩形与给定的rectangle 合并。

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

相关的非成员

bool operator!=(const Qul::PlatformInterface::RectF &r1, const Qul::PlatformInterface::RectF &r2)

如果矩形r1 和r2 不同,则返回true ;否则返回false 。

bool operator==(const Qul::PlatformInterface::RectF &r1, const Qul::PlatformInterface::RectF &r2)

如果矩形r1 和r2 相等,则返回true ;否则返回false 。

在某些 Qt 许可下可用。
了解更多信息。