이 페이지에서

QRectF Class

QRectF 클래스는 부동 소수점 정밀도를 사용하여 평면상의 유한한 직사각형을 정의합니다. 더 보기...

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

참고: 이 클래스의 모든 함수는 재진입 가능합니다.

QRectF 비교

범주비교 가능한 유형
동등성QRectF
동등성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 QRectF &lhs, const QMarginsF &rhs)
QRectF operator+(const QMarginsF &lhs, const QRectF &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는 왼쪽, 위쪽, 너비 및 높이 좌표 집합을 사용하여 생성하거나, QPointF 및 QSizeF 를 사용하여 생성할 수 있습니다. 다음 코드는 두 개의 동일한 사각형을 생성합니다.

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() 함수를 제공합니다:

isEmpty() 함수는 사각형의 너비나 높이가 0 이하일 경우 true 를 반환합니다. 빈 사각형은 유효하지 않다는 점에 유의하십시오. isValid() 함수는 너비와 높이가 모두 0보다 클 경우 true 를 반환합니다. 반면, null 사각형(isNull() == true)은 너비와 높이가 모두 0으로 설정되어 있습니다.

QRect 와 QRectF가 정의된 방식에 따라, 빈 QRectF는 본질적으로 QRect 와 동일한 방식으로 정의된다는 점에 유의하십시오.

마지막으로, QRectF 객체는 비교할 수 있을 뿐만 아니라 스트리밍도 가능합니다.

렌더링

anti-aliased 페인터를 사용할 경우, QRectF의 경계선은 수학적 사각형의 경계선 양쪽에 대칭적으로 렌더링됩니다. 그러나 앨리어싱 페인터(기본값)를 사용할 경우에는 다른 규칙이 적용됩니다.

이 경우, 1픽셀 너비의 펜으로 렌더링하면 QRectF의 경계선이 수학적 사각형의 경계선 오른쪽과 아래쪽에 렌더링됩니다.

2픽셀 너비의 펜으로 렌더링할 경우, 경계선은 수학적 사각선에 의해 중간에서 나뉘게 됩니다. 이는 펜 너비가 짝수 픽셀로 설정된 경우 항상 발생하며, 홀수 픽셀 너비의 펜으로 렌더링할 때는 1픽셀 너비의 경우와 마찬가지로 여분의 픽셀이 수학적 사각선의 오른쪽과 아래쪽으로 렌더링됩니다.

너비와 높이가 표시된 직사각형모서리 좌표를 표시하는 1픽셀 두께의 선으로 그려진 직사각형
논리적 표현1픽셀 너비의 펜
두 픽셀 두께의 펜으로 그려진 사각형과 모서리 좌표모서리 좌표를 표시하는 3픽셀 두께의 펜을 가진 직사각형
2픽셀 너비의 펜3픽셀 너비 펜

좌표

QRectF 클래스는 다양한 사각형 좌표를 반환하고 이를 조작할 수 있게 해주는 일련의 함수들을 제공합니다. 또한 QRectF는 다양한 좌표를 기준으로 사각형을 이동시키는 함수들도 제공합니다.

예를 들어, bottom(), setBottom() 및 moveBottom() 함수가 있습니다. bottom()는 사각형의 하단 가장자리의 y 좌표를 반환하고, setBottom()는 직사각형의 하단 가장자리를 지정된 y 좌표로 설정하며(높이가 변경될 수 있지만, 직사각형의 상단 가장자리는 절대 변경되지 않습니다), moveBottom()는 직사각형의 하단 가장자리를 지정된 y 좌표에 고정하고 크기를 변경하지 않은 채 직사각형 전체를 수직으로 이동시킵니다.

직사각형 다이어그램으로, 위치와 관련된 QRect 메서드(x(), y(), center(), 모서리(topLeft(), topRight(), bottomLeft(), bottomRight()) 및 변(top(), bottom(), left(), right()))를 보여줍니다.

또한 ` adjust()` 함수를 사용하여 이 사각형의 좌표에 오프셋을 추가할 수 있으며, ` adjusted()` 함수를 사용하여 원본 사각형을 조정한 결과를 바탕으로 새로운 사각형을 얻을 수도 있습니다. 너비나 높이가 음수인 경우, ` normalized()` 함수를 사용하여 모서리가 바뀐 사각형을 반환받으십시오.

또한, QRectF는 사각형의 왼쪽 상단 모서리와 오른쪽 하단 모서리의 위치를 추출하는 getCoords() 함수와, 사각형의 왼쪽 상단 모서리, 너비 및 높이를 추출하는 getRect() 함수를 제공합니다. setCoords() 및 setRect() 함수를 사용하여 사각형의 좌표와 크기를 한 번에 조작할 수 있습니다.

QRect 및 QRegion도 참조하십시오 .

멤버 함수 설명서

[constexpr noexcept] QRectF::QRectF()

null 사각형을 생성합니다.

isNull()도 참조하십시오 .

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

주어진 QRect rectangle 를 사용하여 QRectF 사각형을 생성합니다.

참고: 이 함수는 QRect::toRectF()과 마찬가지로, rectangle 의 size()을 보존하며, bottomRight() 모서리는 보존하지 않습니다.

toRect() 및 QRect::toRectF()도 참조하십시오 .

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

주어진 topLeft 및 bottomRight 모서리를 사용하여 직사각형을 생성합니다.

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)를 왼쪽 상단 모서리로 하고, 주어진 width 및 height 를 갖는 직사각형을 생성합니다. 모든 매개변수는 유한해야 합니다.

setRect()함수도 참조하십시오 .

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

직사각형의 기존 좌표에 각각 dx1, dy1, dx2 및 dy2 를 추가합니다. 모든 매개변수는 유한한 값이어야 합니다.

adjusted() 및 setRect()도 참조하십시오 .

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

이 사각형의 기존 좌표에 각각 dx1, dy1, dx2 및 dy2 를 더한 새로운 사각형을 반환합니다. 모든 매개변수는 유한한 값이어야 합니다.

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)

CGRect rect 를 기반으로 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 와 동일하다는 점에 유의하십시오.

두 직사각형 r과 s의 교차 부분을 나타낸 도표로, 겹치는 영역이 강조 표시되어 있습니다. 또한 r.intersect(s).width와 r.intersect(s).height()를 통해 강조 표시된 영역의 너비와 높이가 어떻게 결정되는지 보여줍니다.

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

직사각형이 null 직사각형인 경우 ` true `을 반환하고, 그렇지 않은 경우 ` false`을 반환합니다.

null 사각형은 너비와 높이가 모두 0으로 설정된 사각형입니다. 또한 null 사각형은 비어 있으므로 유효하지 않습니다.

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

정규화된 사각형을 반환합니다. 즉, 너비와 높이가 모두 0보다 큰 사각형입니다.

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)로 설정하고, 크기를 주어진 width 및 height 로 설정합니다. 모든 매개변수는 유한한 값이어야 합니다.

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`의 외곽 사각형을 반환합니다.

두 개의 겹쳐진 사각형 r과 s, 그리고 r.united(s).width와 r.united(s).height()를 통해 결정되는 이들의 합쳐진 크기를 보여주는 다이어그램

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 의 너비와 높이가 모두 대략 0에 가까우면 ` true `을 반환하고, 그렇지 않으면 ` false`을 반환합니다.

이 함수는 Qt 6.8에서 도입되었습니다.

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

직사각형 lhs 과 rhs 가 충분히 다른 경우 true 를 반환하고, 그렇지 않은 경우 false 를 반환합니다.

경고: 이 함수는 엄격한 불등식을 확인하지 않으며, 대신 퍼지 비교를 사용하여 직사각형의 좌표를 비교합니다.

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

` lhs ` 직사각형을 ` rhs ` 여백만큼 확대한 결과를 반환합니다.

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

` lhs ` 사각형을 ` rhs ` 마진만큼 확장한 사각형을 반환합니다.

이 함수는 오버로드된 함수입니다.

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

` lhs ` 사각형을 ` rhs ` 여백만큼 축소하여 반환합니다.

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

rectangle 를 stream 에 기록하고, 해당 스트림에 대한 참조를 반환합니다.

'Qt 데이터 유형 직렬화'항목도 참조하십시오 .

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

직사각형 lhs 과 rhs 이 대략적으로 같을 경우 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

경고: 이 함수는 엄격한 등가 여부를 확인하지 않으며, 대신 직사각형의 좌표를 비교할 때 근사적 비교를 사용합니다.

qFuzzyCompare도 참조하십시오 .

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

stream 에서 ` rectangle `를 읽어들이고, 해당 스트림에 대한 참조를 반환합니다.

Qt 데이터 유형의 직렬화항목도 참조하십시오 .

© 2026 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.