QPainterPath Class
QPainterPath 클래스는 그리기 작업을 위한 컨테이너를 제공하여 그래픽 도형을 생성하고 재사용할 수 있게 해줍니다. 더 보기...
| 헤더: | #include <QPainterPath> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
| qmake: | QT += gui |
- 상속된 멤버를 포함한 모든 멤버 목록
- QPainterPath는 페인팅 클래스의 일부입니다.
참고: 이 클래스의 모든 함수는 재진입 가능합니다.
공개 유형
| class | Element |
| enum | ElementType { MoveToElement, LineToElement, CurveToElement, CurveToDataElement } |
공개 함수
| QPainterPath() | |
| QPainterPath(const QPointF &startPoint) | |
| QPainterPath(const QPainterPath &path) | |
(since 6.10) | QPainterPath(QPainterPath &&other) |
| ~QPainterPath() | |
| void | addEllipse(const QRectF &boundingRectangle) |
| void | addEllipse(const QPointF ¢er, qreal rx, qreal ry) |
| void | addEllipse(qreal x, qreal y, qreal width, qreal height) |
| void | addPath(const QPainterPath &path) |
| void | addPolygon(const QPolygonF &polygon) |
| void | addRect(const QRectF &rectangle) |
| void | addRect(qreal x, qreal y, qreal width, qreal height) |
| void | addRegion(const QRegion ®ion) |
| void | addRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize) |
| void | addRoundedRect(qreal x, qreal y, qreal w, qreal h, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize) |
| void | addText(const QPointF &point, const QFont &font, const QString &text) |
| void | addText(qreal x, qreal y, const QFont &font, const QString &text) |
| qreal | angleAtPercent(qreal t) const |
| void | arcMoveTo(const QRectF &rectangle, qreal angle) |
| void | arcMoveTo(qreal x, qreal y, qreal width, qreal height, qreal angle) |
| void | arcTo(const QRectF &rectangle, qreal startAngle, qreal sweepLength) |
| void | arcTo(qreal x, qreal y, qreal width, qreal height, qreal startAngle, qreal sweepLength) |
| QRectF | boundingRect() const |
| int | capacity() const |
| void | clear() |
| void | closeSubpath() |
| void | connectPath(const QPainterPath &path) |
| bool | contains(const QPainterPath &p) const |
| bool | contains(const QPointF &point) const |
| bool | contains(const QRectF &rectangle) const |
| QRectF | controlPointRect() const |
| void | cubicTo(const QPointF &c1, const QPointF &c2, const QPointF &endPoint) |
| void | cubicTo(qreal c1X, qreal c1Y, qreal c2X, qreal c2Y, qreal endPointX, qreal endPointY) |
| QPointF | currentPosition() const |
| QPainterPath::Element | elementAt(int index) const |
| int | elementCount() const |
| Qt::FillRule | fillRule() const |
| QPainterPath | intersected(const QPainterPath &p) const |
| bool | intersects(const QPainterPath &p) const |
| bool | intersects(const QRectF &rectangle) const |
(since 6.10) bool | isCachingEnabled() const |
| bool | isEmpty() const |
| qreal | length() const |
| void | lineTo(const QPointF &endPoint) |
| void | lineTo(qreal x, qreal y) |
| void | moveTo(const QPointF &point) |
| void | moveTo(qreal x, qreal y) |
| qreal | percentAtLength(qreal len) const |
| QPointF | pointAtPercent(qreal t) const |
| void | quadTo(const QPointF &c, const QPointF &endPoint) |
| void | quadTo(qreal cx, qreal cy, qreal endPointX, qreal endPointY) |
| void | reserve(int size) |
(since 6.10) void | setCachingEnabled(bool enabled) |
| void | setElementPositionAt(int index, qreal x, qreal y) |
| void | setFillRule(Qt::FillRule fillRule) |
| QPainterPath | simplified() const |
| qreal | slopeAtPercent(qreal t) const |
| QPainterPath | subtracted(const QPainterPath &p) const |
| void | swap(QPainterPath &other) |
| QPolygonF | toFillPolygon(const QTransform &matrix = QTransform()) const |
| QList<QPolygonF> | toFillPolygons(const QTransform &matrix = QTransform()) const |
| QPainterPath | toReversed() const |
| QList<QPolygonF> | toSubpathPolygons(const QTransform &matrix = QTransform()) const |
| void | translate(qreal dx, qreal dy) |
| void | translate(const QPointF &offset) |
| QPainterPath | translated(qreal dx, qreal dy) const |
| QPainterPath | translated(const QPointF &offset) const |
(since 6.10) QPainterPath | trimmed(qreal fromFraction, qreal toFraction, qreal offset = 0) const |
| QPainterPath | united(const QPainterPath &p) const |
| bool | operator!=(const QPainterPath &path) const |
| QPainterPath | operator&(const QPainterPath &other) const |
| QPainterPath & | operator&=(const QPainterPath &other) |
| QPainterPath | operator+(const QPainterPath &other) const |
| QPainterPath & | operator+=(const QPainterPath &other) |
| QPainterPath | operator-(const QPainterPath &other) const |
| QPainterPath & | operator-=(const QPainterPath &other) |
| QPainterPath & | operator=(QPainterPath &&other) |
| QPainterPath & | operator=(const QPainterPath &path) |
| bool | operator==(const QPainterPath &path) const |
| QPainterPath | operator|(const QPainterPath &other) const |
| QPainterPath & | operator|=(const QPainterPath &other) |
관련 비회원
| QDataStream & | operator<<(QDataStream &stream, const QPainterPath &path) |
| QDataStream & | operator>>(QDataStream &stream, QPainterPath &path) |
상세 설명
페인터 경로는 사각형, 타원, 선, 곡선과 같은 여러 그래픽 구성 요소로 구성된 개체입니다. 구성 요소들은 사각형이나 타원과 같이 닫힌 하위 경로로 결합될 수 있습니다. 닫힌 경로는 시작점과 끝점이 일치합니다. 또는 선이나 곡선과 같이 닫히지 않은 하위 경로로 독립적으로 존재할 수도 있습니다.
QPainterPath 객체는 채우기, 윤곽 그리기 및 자르기에 사용할 수 있습니다. 주어진 페인터 경로에 대해 채울 수 있는 윤곽을 생성하려면 QPainterPathStroker 클래스를 사용하십시오. 일반적인 그리기 작업에 비해 페인터 경로의 주요 장점은 복잡한 도형을 한 번만 생성하면 되며, 이후에는 QPainter::drawPath() 함수를 호출하는 것만으로 여러 번 그릴 수 있다는 점입니다.
QPainterPath는 경로 및 그 요소에 대한 정보를 얻기 위해 사용할 수 있는 일련의 함수를 제공합니다. 또한 toReversed() 함수를 사용하여 요소의 순서를 반대로 바꿀 수도 있습니다. 이 페인터 경로 객체를 다각형 표현으로 변환하는 여러 함수도 있습니다.
QPainterPath 구성
QPainterPath 객체는 빈 경로, 지정된 시작점을 가진 경로, 또는 다른 QPainterPath 객체의 복사본으로 생성될 수 있습니다. 생성된 후에는 lineTo(), arcTo(), cubicTo() 및 quadTo() 함수를 사용하여 경로에 선과 곡선을 추가할 수 있습니다. 선과 곡선은 ` currentPosition()`에서 인수로 전달된 위치까지 뻗어 나갑니다.
QPainterPath 객체의 currentPosition()은 항상 마지막으로 추가된 하위 경로의 끝 위치(또는 초기 시작점)입니다. moveTo() 함수를 사용하면 구성 요소를 추가하지 않고 currentPosition()을 이동할 수 있습니다. moveTo() 함수는 암시적으로 새로운 하위 경로를 시작하고, 이전 경로를 닫습니다. 새로운 서브패스를 시작하는 또 다른 방법은 closeSubpath() 함수를 호출하는 것으로, 이 함수는 currentPosition()에서 패스의 시작 위치로 돌아가는 선을 추가하여 현재 패스를 닫습니다. 새로운 패스의 초기 좌표는 (0, 0)이 된다는 점에 유의하십시오 currentPosition().
QPainterPath 클래스는 페인터 경로에 닫힌 하위 경로를 추가하기 위한 몇 가지 편리한 함수도 제공합니다: addEllipse(), addPath(), addRect(), addRegion() 및 addText(). addPolygon() 함수는 닫히지 않은 하위 경로를 추가합니다. 사실, 이러한 함수들은 모두 moveTo(), lineTo() 및 cubicTo() 연산의 조합입니다.
또한, connectPath() 함수를 사용하여 현재 경로에 경로를 추가할 수 있습니다. 하지만 이 함수는 선을 추가하여 현재 경로의 마지막 요소와 주어진 경로의 첫 번째 요소를 연결한다는 점에 유의하십시오.
다음은 QPainterPath 객체를 사용하는 방법을 보여주는 코드 예시입니다:
![]() | |
페인터 경로는 생성될 때 처음에는 비어 있습니다. 먼저 닫힌 하위 경로인 사각형을 추가합니다. 그런 다음 개별적으로는 닫혀 있지 않더라도 함께 닫힌 하위 경로를 형성하는 두 개의 베지어 곡선을 추가합니다. 마지막으로 전체 경로를 그립니다. 경로는 기본 채우기 규칙인 Qt::OddEvenFill 를 사용하여 채워집니다. Qt는 경로를 채우기 위한 두 가지 방법을 제공합니다:
규칙에 대한 정의는 Qt::FillRule 문서를 참조하십시오. 페인터 경로의 현재 설정된 채우기 규칙은 fillRule() 함수를 사용하여 가져올 수 있으며, setFillRule() 함수를 사용하여 변경할 수 있습니다.
호와 타원
arcTo(), arcMoveTo(), QPainter::drawArc(), QPainter::drawPie() 및 QPainter::drawChord()의 각도 인수는 편심각입니다. 편심각은 경계 사각형에 들어맞는 타원을 매개변수화하는 것으로, 해당 사각형의 중심에서 결과 점까지의 방향을 측정하는 것이 아닙니다. 일반적으로 이 두 값은 경계 사각형이 정사각형일 때만 일치합니다. 예를 들어, 400×100 크기의 사각형에서 45도의 각도는 중심에서 보았을 때 수평선보다 대략 14도 위쪽에 위치한 점을 산출합니다.
대신 중심에서 주어진 방향으로 점을 배치하려면, 해당 점을 직접 계산하여 moveTo() 또는 lineTo()에 전달하십시오. 또는, 이 함수들을 계속 사용하면서 방향을 변환할 수도 있습니다. 주어진 width 및 height 의 경계 사각형에서, 라디안 단위의 방향 theta 은 편심각 qRadiansToDegrees(qAtan2(width * qSin(theta), height * qCos(theta))) 에 해당합니다.
페인터 경로는 선과 베지어 세그먼트만 저장하기 때문에, Qt는 호와 타원을 삼차 베지어 곡선으로 근사화하며 삼각함수를 사용하여 계산하지 않습니다. 원의 경우, 이 근사값으로 인해 점들이 실제 위치에서 반지름의 0.1% 미만의 오차를 보입니다. 따라서 arcMoveTo()에서 반환된 점과 qSin() 및 qCos()로 계산된 점을 비교하는 코드는, 두 점이 동일한지 테스트하는 대신 허용 오차를 고려해야 합니다.
QPainterPath 정보
QPainterPath 클래스는 경로 및 그 요소에 대한 정보를 반환하는 일련의 함수를 제공합니다.
currentPosition() 함수는 마지막으로 추가된 하위 경로의 끝점(또는 초기 시작점)을 반환합니다. elementAt() 함수는 다양한 하위 경로 요소를 가져오는 데 사용할 수 있으며, elementCount() 함수를 사용하여 요소의 개수를 가져올 수 있고, isEmpty() 함수는 이 QPainterPath 객체에 요소가 포함되어 있는지 여부를 알려줍니다.
controlPointRect() 함수는 이 경로에 포함된 모든 점과 제어점을 포함하는 사각형을 반환합니다. 이 함수는 부동 소수점 정밀도로 이 페인터 경로의 경계 사각형을 반환하는 정확한 boundingRect() 함수보다 계산 속도가 훨씬 빠릅니다.
마지막으로, QPainterPath는 주어진 점이나 사각형이 경로 내에 있는지 여부를 확인하는 데 사용할 수 있는 contains() 함수와, 주어진 사각형 내의 점 중 어느 하나라도 이 경로 내에 있는지 여부를 확인하는 intersects() 함수를 제공합니다.
QPainterPath 변환
호환성상의 이유로 페인터 경로의 표현을 단순화해야 할 수도 있습니다. QPainterPath는 페인터 경로를 다각형으로 변환하는 toFillPolygon(), toFillPolygons() 및 toSubpathPolygons() 함수를 제공합니다. toFillPolygon()는 페인터 경로를 단일 다각형으로 반환하는 반면, 나머지 두 함수는 다각형 목록을 반환합니다.
toFillPolygons() 및 toSubpathPolygons() 함수는 그려지는 점의 총 개수가 동일하더라도, 하나의 큰 다각형을 그리는 것보다 여러 개의 작은 다각형을 그리는 것이 일반적으로 더 빠르기 때문에 제공됩니다. 이 두 함수의 차이점은 반환하는 다각형의 수에 있습니다. ` toSubpathPolygons()`은 교차하는 하위 경로(즉, 바운딩 사각형이 겹치는 경우)에 관계없이 각 하위 경로마다 하나의 다각형을 생성하는 반면, ` toFillPolygons()` 함수는 겹치는 하위 경로에 대해 하나의 다각형만 생성합니다.
toFillPolygon() 및 toFillPolygons() 함수는 먼저 모든 하위 경로를 다각형으로 변환한 다음, 되감기 기법을 사용하여 겹치는 하위 경로가 올바른 채우기 규칙에 따라 채워지도록 합니다. 되감기 과정에서는 다각형 내에 추가 선분이 삽입되므로, 채워진 다각형의 윤곽선이 경로의 윤곽선과 일치하지 않는다는 점에 유의하십시오.
예제
Qt는 Qt의 예제 디렉터리에 위치한 ‘Painter Paths 예제’와 ‘벡터 변형 예제’를 제공합니다.
'Painter Paths 예제'는 페인터 경로를 사용하여 렌더링할 복잡한 도형을 만드는 방법을 보여주고, 사용자가 채우기와 선 그리기를 직접 실험해 볼 수 있게 해줍니다. '벡터 변형 예제'는 QPainterPath를 사용하여 텍스트를 그리는 방법을 보여줍니다.
QPainterPathStroker, QPainter, QRegion 및 페인터 경로 예제를참조하십시오 .
멤버 유형 문서
enum QPainterPath::ElementType
이 열거형은 하위 경로에서 정점을 연결하는 데 사용되는 요소의 유형을 설명합니다.
addEllipse(), addPath(), addPolygon(), addRect(), addRegion() 및 addText() 편의 함수를 사용하여 닫힌 하위 경로로 추가된 요소는, 실제로는 moveTo(), lineTo() 및 cubicTo() 함수를 사용하여 별도의 요소 모음으로 경로에 추가된다는 점에 유의하십시오.
| 상수 | 값 | 설명 |
|---|---|---|
QPainterPath::MoveToElement | 0 | 새로운 하위 경로입니다. moveTo()도 참조하십시오. |
QPainterPath::LineToElement | 1 | 선. lineTo()도 참조하십시오. |
QPainterPath::CurveToElement | 2 | 곡선. cubicTo() 및 quadTo()도 참조하십시오. |
QPainterPath::CurveToDataElement | 3 | CurveToElement 요소에서 곡선을 설명하는 데 필요한 추가 데이터. |
elementAt() 및 elementCount()도 참조하십시오 .
멤버 함수 설명서
[noexcept] QPainterPath::QPainterPath()
빈 QPainterPath 객체를 생성합니다.
[explicit] QPainterPath::QPainterPath(const QPointF &startPoint)
지정된 ` startPoint `를 현재 위치로 설정하여 `QPainterPath` 객체를 생성합니다.
QPainterPath::QPainterPath(const QPainterPath &path)
지정된 ` path`의 복사본인 `QPainterPath` 객체를 생성합니다.
operator=()도 참조하십시오 .
[noexcept, since 6.10] QPainterPath::QPainterPath(QPainterPath &&other)
other 에서 새로운 페인터 경로를 생성합니다.
이동된 객체 other 는 기본 생성된 상태로 설정됩니다.
이 함수는 Qt 6.10에서 도입되었습니다.
[noexcept] QPainterPath::~QPainterPath()
이 QPainterPath 객체를 삭제합니다.
void QPainterPath::addEllipse(const QRectF &boundingRectangle)
지정된 타원 좌표계( boundingRectangle ) 내에서 타원을 생성하고, 이를 닫힌 하위 경로로 페인터 경로에 추가합니다.
이 타원은 0도(3시 방향)에서 시작하여 0도에서 끝나는 시계 방향 곡선으로 구성됩니다. 이 곡선은 Arcs and Ellipses 에 설명된 바와 같이 타원을 정확히 표현한 것이 아니라, 타원에 대한 3차 베지어 근사치입니다.
![]() | |
arcTo(), QPainter::drawEllipse(), Composing a QPainterPath도 참조하십시오 .
void QPainterPath::addEllipse(const QPointF ¢er, qreal rx, qreal ry)
center 에 위치하고 반지름이 rx 및 ry 인 타원을 생성하여, 이를 닫힌 하위 경로로 페인터 경로에 추가합니다.
이 함수는 오버로드된 함수입니다.
void QPainterPath::addEllipse(qreal x, qreal y, qreal width, qreal height)
(x, y), width 및 height 로 정의된 경계 사각형 내에 타원을 생성하고, 이를 닫힌 하위 경로로 페인터 경로에 추가합니다.
이 함수는 오버로드된 함수입니다.
void QPainterPath::addPath(const QPainterPath &path)
지정된 path 를 이 경로에 닫힌 하위 경로로 추가합니다.
connectPath() 및 Composing a QPainterPath도 참조하십시오 .
void QPainterPath::addPolygon(const QPolygonF &polygon)
지정된 다각형( polygon )을 경로에 (닫히지 않은) 하위 경로로 추가합니다.
다각형이 추가된 후의 현재 위치는 polygon 의 마지막 점임을 유의하십시오. 첫 번째 점으로 돌아가는 선을 그리려면 closeSubpath() 함수를 사용하십시오.
![]() | |
lineTo() 및 Composing a QPainterPath도 참조하십시오 .
void QPainterPath::addRect(const QRectF &rectangle)
지정된 rectangle 를 이 경로에 닫힌 하위 경로로 추가합니다.
rectangle 는 시계 방향으로 이어지는 선의 집합으로 추가됩니다. rectangle 가 추가된 후 페인터 경로의 현재 위치는 사각형의 왼쪽 상단 모서리에 있습니다.
![]() | |
addRegion(), lineTo(), Composing a QPainterPath도 참조하십시오 .
void QPainterPath::addRect(qreal x, qreal y, qreal width, qreal height)
(x, y) 위치에, 주어진 width 및 height 을 가진 사각형을 닫힌 부분 경로로 추가합니다.
이 함수는 오버로드된 함수입니다.
void QPainterPath::addRegion(const QRegion ®ion)
지정된 영역( region )을 경로에 추가하며, 영역 내의 각 사각형을 별도의 닫힌 부분 경로로 추가합니다.
addRect() 및 Composing a QPainterPath도 참조하십시오 .
void QPainterPath::addRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize)
지정된 직사각형 rect 의 모서리를 둥글게 처리하여 경로에 추가합니다.
xRadius 및 yRadius 인수는 모서리가 둥근 사각형의 모서리를 정의하는 타원의 반지름을 지정합니다. mode 가 Qt::RelativeSize 인 경우, xRadius 및 yRadius 는 각각 사각형의 너비와 높이의 절반을 기준으로 한 백분율로 지정되며, 0.0에서 100.0 사이의 값이어야 합니다.
addRect()도 참조하십시오 .
void QPainterPath::addRoundedRect(qreal x, qreal y, qreal w, qreal h, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize)
지정된 직사각형 x, y, w, h 의 모서리를 둥글게 처리하여 경로에 추가합니다.
이 함수는 오버로드된 함수입니다.
void QPainterPath::addText(const QPointF &point, const QFont &font, const QString &text)
지정된 ‘ text ’를 이 경로에, 제공된 ‘ font ’를 기반으로 생성된 닫힌 하위 경로 집합으로 추가합니다. 하위 경로들은 텍스트의 기준선 왼쪽 끝이 지정된 ‘ point ’에 위치하도록 배치됩니다.
일부 글꼴의 경우 하위 경로가 겹칠 수 있으며, 올바른 렌더링을 위해서는 Qt::WindingFill 채우기 규칙이 필요합니다.
![]() | |
QPainter::drawText(), Composing a QPainterPath 및 setFillRule()도 참조하십시오 .
void QPainterPath::addText(qreal x, qreal y, const QFont &font, const QString &text)
지정된 ` text `를, 제공된 ` font `를 기반으로 생성된 닫힌 하위 경로 집합으로 이 경로에 추가합니다. 하위 경로들은 텍스트의 기준선 왼쪽 끝이 (x, y)로 지정된 지점에 오도록 배치됩니다.
이 함수는 오버로드된 함수입니다.
qreal QPainterPath::angleAtPercent(qreal t) const
t 에서 경로의 접선 각도를 반환합니다. 인자 t 는 0과 1 사이여야 합니다.
각도의 양수 값은 시계 반대 방향을, 음수 값은 시계 방향임을 의미합니다. 0도는 3시 방향에 해당합니다.
다른 퍼센트 메서드와 마찬가지로, 경로에 곡선이 포함된 경우 퍼센트 측정값은 길이와 선형적인 관계가 아님을 유의하십시오. 곡선이 포함된 경우, 퍼센트 인수는 베지어 방정식의 t 매개변수로 매핑됩니다.
void QPainterPath::arcMoveTo(const QRectF &rectangle, qreal angle)
angle 에서 주어진 rectangle 를 차지하는 호 위에 위치한 이동을 생성합니다.
각도는 도(degree) 단위로 지정됩니다. 시계 방향 호는 음의 각도를 사용하여 지정할 수 있습니다. rectangle 가 정사각형이 아닌 경우, angle 는 편심각이며, Arcs and Ellipses 에 설명된 바와 같이 직사각형의 중심에서 방향을 측정하지 않습니다.
moveTo(), arcTo() 및 Arcs and Ellipses도 참조하십시오 .
void QPainterPath::arcMoveTo(qreal x, qreal y, qreal width, qreal height, qreal angle)
angle 에서 QRectF(x, y, width, height)을 차지하는 호 위에 위치한 이동을 생성합니다.
이 함수는 오버로드된 함수입니다.
void QPainterPath::arcTo(const QRectF &rectangle, qreal startAngle, qreal sweepLength)
지정된 rectangle 영역을 차지하는 호를 생성하며, 이 호는 지정된 startAngle 에서 시작하여 시계 반대 방향으로 sweepLength 도까지 뻗어 나갑니다.
각도는 도(degree) 단위로 지정됩니다. 시계 방향 호는 음의 각도를 사용하여 지정할 수 있습니다. rectangle 가 정사각형이 아닌 경우, 각도는 편심각이며 Arcs and Ellipses 에 설명된 대로 직사각형의 중심에서 방향을 측정하지 않습니다.
이 함수는 호의 시작점과 현재 위치가 아직 연결되어 있지 않은 경우, 두 점을 연결한다는 점에 유의하십시오. 호가 추가된 후, 현재 위치는 호의 마지막 점이 됩니다. 첫 번째 점으로 돌아가는 선을 그리려면 closeSubpath() 함수를 사용하십시오.
![]() | |
arcMoveTo(), addEllipse(), QPainter::drawArc(), QPainter::drawPie() 및 Composing a QPainterPath도 참조하십시오 .
void QPainterPath::arcTo(qreal x, qreal y, qreal width, qreal height, qreal startAngle, qreal sweepLength)
QRectF(x, y, width, height) 직사각형 영역을 차지하는 호를 생성하며, 지정된 startAngle 에서 시작하여 시계 반대 방향으로 sweepLength 도까지 뻗어 나갑니다.
이 함수는 오버로드된 함수입니다.
QRectF QPainterPath::boundingRect() const
이 페인터 경로의 경계 사각형을 부동 소수점 정밀도를 가진 사각형으로 반환합니다.
controlPointRect()도 참조하십시오 .
int QPainterPath::capacity() const
QPainterPath 에 의해 할당된 요소의 개수를 반환합니다.
void QPainterPath::clear()
저장된 경로 요소를 지웁니다.
이를 통해 경로는 이전에 할당된 메모리를 재사용할 수 있습니다.
reserve() 및 capacity()도 참조하십시오 .
void QPainterPath::closeSubpath()
현재 하위 경로의 시작점으로 선을 그려 해당 하위 경로를 닫고, 자동으로 새로운 경로를 시작합니다. 새로운 경로의 현재 점은 (0, 0)입니다.
서브패스에 요소가 하나도 포함되어 있지 않으면, 이 함수는 아무 작업도 수행하지 않습니다.
moveTo() 및 Composing a QPainterPath도 참조하십시오 .
void QPainterPath::connectPath(const QPainterPath &path)
지정된 경로( path )를 이 경로와 연결하며, 이 경로의 마지막 요소에서 지정된 경로의 첫 번째 요소로 이어지는 선을 추가합니다.
addPath() 및 Composing a QPainterPath도 참조하십시오 .
bool QPainterPath::contains(const QPainterPath &p) const
주어진 경로 p 가 현재 경로 내에 포함되어 있으면 true 를 반환합니다. 현재 경로의 가장자리 중 하나와 p 의 가장자리가 교차하면 false 를 반환합니다.
경로에 대한 집합 연산은 경로를 영역으로 취급합니다. 닫히지 않은 경로는 암묵적으로 닫힌 경로로 취급됩니다.
intersects()도 참조하십시오 .
bool QPainterPath::contains(const QPointF &point) const
지정된 point 가 경로 내에 있으면 true 를 반환하고, 그렇지 않으면 false 를 반환합니다.
intersects()도 참조하십시오 .
bool QPainterPath::contains(const QRectF &rectangle) const
지정된 ` rectangle `가 경로 내에 있으면 ` true `을 반환하고, 그렇지 않으면 ` false`을 반환합니다.
QRectF QPainterPath::controlPointRect() const
이 경로에 포함된 모든 점과 제어점을 포함하는 사각형을 반환합니다.
이 함수는 정확한 boundingRect() 함수보다 계산 속도가 훨씬 빠르며, 반환되는 직사각형은 항상 boundingRect() 함수가 반환하는 직사각형의 상집합입니다.
boundingRect()도 참조하십시오 .
void QPainterPath::cubicTo(const QPointF &c1, const QPointF &c2, const QPointF &endPoint)
c1 와 c2 에 지정된 제어점을 사용하여, 현재 위치와 주어진 endPoint 사이에 3차 베지어 곡선을 추가합니다.
곡선이 추가된 후, 현재 위치는 곡선의 끝점에 위치하도록 업데이트됩니다.
![]() | |
quadTo() 및 Composing a QPainterPath도 참조하십시오 .
void QPainterPath::cubicTo(qreal c1X, qreal c1Y, qreal c2X, qreal c2Y, qreal endPointX, qreal endPointY)
현재 위치와 끝점(endPointX, endPointY) 사이에, (c1X, c1Y) 및 (c2X, c2Y)로 지정된 제어점을 갖는 3차 베지어 곡선을 추가합니다.
이 함수는 오버로드된 함수입니다.
QPointF QPainterPath::currentPosition() const
경로의 현재 위치를 반환합니다.
QPainterPath::Element QPainterPath::elementAt(int index) const
페인터 경로에서 지정된 index 에 있는 요소를 반환합니다.
ElementType, elementCount() 및 isEmpty()도 참조하십시오 .
int QPainterPath::elementCount() const
페인터 경로에 포함된 경로 요소의 개수를 반환합니다.
ElementType, elementAt(), isEmpty()도 참조하십시오 .
Qt::FillRule QPainterPath::fillRule() const
페인터 경로의 현재 설정된 채우기 규칙을 반환합니다.
setFillRule()도 참조하십시오 .
QPainterPath QPainterPath::intersected(const QPainterPath &p) const
이 경로의 채움 영역과 p 의 채움 영역이 교차하는 경로를 반환합니다. 베지어 곡선의 교차 연산을 수행할 때 수치적 불안정성으로 인해 베지어 곡선이 선분으로 평탄화될 수 있습니다.
bool QPainterPath::intersects(const QPainterPath &p) const
현재 경로가 주어진 경로 p 와 어느 지점에서든 교차하는 경우 true 를 반환합니다. 또한 현재 경로가 p 의 일부를 포함하거나 의 일부에 포함되는 경우 true 를 반환합니다.
경로에 대한 집합 연산은 경로를 영역으로 취급합니다. 닫히지 않은 경로는 암묵적으로 닫힌 경로로 취급됩니다.
contains()도 참조하십시오 .
bool QPainterPath::intersects(const QRectF &rectangle) const
주어진 rectangle 내의 어떤 점이 경로와 교차하면 true 를 반환하고, 그렇지 않으면 false 를 반환합니다.
직사각형( )을 구성하는 선 중 어느 하나라도 경로의 일부와 교차하거나, 직사각형의 어느 부분이라도 경로가 둘러싼 영역과 겹치는 경우 교차가 있는 것으로 간주합니다. 이 함수는 경로 내부를 판단할 때 현재 fillRule 을 따릅니다.
contains()함수도 참조하십시오 .
[since 6.10] bool QPainterPath::isCachingEnabled() const
캐싱이 활성화되어 있으면 true를 반환하고, 그렇지 않으면 false를 반환합니다.
이 함수는 Qt 6.10에서 도입되었습니다.
setCachingEnabled()도 참조하십시오 .
bool QPainterPath::isEmpty() const
이 경로에 요소가 없거나, 유일한 요소가 ` MoveToElement`인 경우 ` true `을 반환하고, 그렇지 않은 경우 ` false`을 반환합니다.
elementCount()도 참조하십시오 .
qreal QPainterPath::length() const
현재 경로의 길이를 반환합니다.
void QPainterPath::lineTo(const QPointF &endPoint)
현재 위치에서 지정된 endPoint 까지 직선을 그립니다. 선이 그려진 후, 현재 위치는 선의 끝점으로 업데이트됩니다.
addPolygon(), addRect(), Composing a QPainterPath도 참조하십시오 .
void QPainterPath::lineTo(qreal x, qreal y)
현재 위치에서 점 (x, y)까지 선을 그립니다.
이 함수는 오버로드된 함수입니다.
void QPainterPath::moveTo(const QPointF &point)
현재 지점을 지정된 point 로 이동시키며, 이 과정에서 암묵적으로 새로운 하위 경로를 시작하고 이전 경로를 종료합니다.
closeSubpath() 및 Composing a QPainterPath도 참조하십시오 .
void QPainterPath::moveTo(qreal x, qreal y)
현재 위치를 (x, y)로 이동시키고 새로운 하위 경로를 시작하며, 이전 경로는 암시적으로 닫습니다.
이 함수는 오버로드된 함수입니다.
qreal QPainterPath::percentAtLength(qreal len) const
지정된 길이 len 에서 전체 경로의 백분율을 반환합니다.
다른 퍼센트 메서드와 마찬가지로, 경로에 곡선이 포함된 경우 백분율 측정은 길이에 대해 선형적으로 변하지 않는다는 점에 유의하십시오. 곡선이 포함된 경우, 백분율 인수는 베지어 방정식의 t 매개변수에 매핑됩니다.
QPointF QPainterPath::pointAtPercent(qreal t) const
현재 경로의 t 에 해당하는 지점을 반환합니다. 인자 t 는 0과 1 사이여야 합니다.
다른 퍼센트 메서드와 마찬가지로, 경로에 곡선이 포함된 경우 퍼센트 측정은 길이에 대해 선형적이지 않다는 점에 유의하십시오. 곡선이 포함된 경우, 퍼센트 인수는 베지어 방정식의 t 매개변수로 매핑됩니다.
void QPainterPath::quadTo(const QPointF &c, const QPointF &endPoint)
현재 위치와 지정된 시작점( endPoint ) 사이에, c 로 지정된 제어점을 사용하여 2차 베지어 곡선을 추가합니다.
곡선이 추가된 후, 현재 점은 곡선의 끝점에 위치하도록 업데이트됩니다.
cubicTo() 및 Composing a QPainterPath도 참조하십시오 .
void QPainterPath::quadTo(qreal cx, qreal cy, qreal endPointX, qreal endPointY)
현재 점과 끝점(endPointX, endPointY) 사이에, (cx, cy)로 지정된 제어점을 갖는 2차 베지어 곡선을 추가합니다.
이 함수는 오버로드된 함수입니다.
void QPainterPath::reserve(int size)
QPainterPath 의 내부 메모리에 지정된 개수의 요소를 할당합니다.
최소 size 개의 요소에 대한 메모리를 할당하려고 시도합니다.
clear(), capacity(), QList::reserve()도 참조하십시오 .
[since 6.10] void QPainterPath::setCachingEnabled(bool enabled)
enabled 의 값에 따라 길이 캐싱을 활성화하거나 비활성화합니다.
캐싱을 활성화하면 length(), percentAtLength(), pointAtPercent() 등과 같이 경로 길이와 백분율 값을 다루는 멤버 함수에 대한 반복 호출 속도가 빨라지지만, 중간 계산 결과를 저장하기 위해 추가 메모리가 소모됩니다. 기본적으로 비활성화되어 있습니다.
캐싱을 비활성화하면 할당된 캐시 메모리가 모두 해제됩니다.
이 함수는 Qt 6.10에서 도입되었습니다.
isCachingEnabled(), length(), percentAtLength(), pointAtPercent() 및 trimmed()도 참조하십시오 .
void QPainterPath::setElementPositionAt(int index, qreal x, qreal y)
인덱스 index 에 있는 요소의 x 및 y 좌표를 각각 x 및 y 로 설정합니다.
void QPainterPath::setFillRule(Qt::FillRule fillRule)
페인터 경로의 채우기 규칙을 지정된 ` fillRule`로 설정합니다. Qt는 경로를 채우는 두 가지 방법을 제공합니다:
fillRule()도 참조하십시오 .
QPainterPath QPainterPath::simplified() const
이 경로의 단순화된 버전을 반환합니다. 이는 교차하는 모든 하위 경로를 병합하고, 교차하는 변이 포함되지 않은 경로를 반환함을 의미합니다. 연속된 평행선도 병합됩니다. 단순화된 경로는 항상 기본 채우기 규칙인 ‘ Qt::OddEvenFill ’을 사용합니다. 베지어 곡선의 교차 연산 시 발생할 수 있는 수치적 불안정성으로 인해, 베지어 곡선이 선분으로 평탄화될 수 있습니다.
qreal QPainterPath::slopeAtPercent(qreal t) const
t 에 해당하는 경로의 기울기를 반환합니다. 인자 t 는 0과 1 사이여야 합니다.
다른 퍼센트 메서드와 마찬가지로, 경로에 곡선이 포함된 경우 퍼센트 측정값은 길이에 대해 선형적이지 않다는 점에 유의하십시오. 곡선이 포함된 경우, 퍼센트 인수는 베지어 방정식의 t 매개변수로 매핑됩니다.
QPainterPath QPainterPath::subtracted(const QPainterPath &p) const
이 경로의 채움 영역에서 ` p`의 채움 영역을 뺀 경로를 반환합니다.
경로에 대한 집합 연산에서는 경로를 영역으로 취급합니다. 닫히지 않은 경로는 암묵적으로 닫힌 것으로 간주됩니다. 베지어 곡선의 교차 연산 시 발생할 수 있는 수치적 불안정성으로 인해, 베지어 곡선이 선분으로 평탄화될 수 있습니다.
[noexcept] void QPainterPath::swap(QPainterPath &other)
이 페인터 경로를 other 로 바꿉니다. 이 작업은 매우 빠르며 절대 실패하지 않습니다.
QPolygonF QPainterPath::toFillPolygon(const QTransform &matrix = QTransform()) const
QTransform matrix 를 사용하여 경로를 다각형으로 변환하고, 변환된 다각형을 반환합니다.
다각형은 먼저 모든 하위 경로를 다각형으로 변환한 다음, 리와인딩 기법을 사용하여 겹치는 하위 경로가 올바른 채우기 규칙에 따라 채워지도록 함으로써 생성됩니다.
되감기(rewinding)는 다각형에 추가 선을 삽입하므로, 채워진 다각형의 윤곽선이 경로의 윤곽선과 일치하지 않는다는 점에 유의하십시오.
toSubpathPolygons(), toFillPolygons() 및 QPainterPath Conversion도 참조하십시오 .
QList<QPolygonF> QPainterPath::toFillPolygons(const QTransform &matrix = QTransform()) const
QTransform matrix 를 사용하여 경로를 다각형 목록으로 변환하고, 해당 목록을 반환합니다.
이 함수는 여러 개의 다각형을 생성한다는 점에서 toFillPolygon() 함수와 다릅니다. 그려지는 점의 총 개수는 동일하더라도, 하나의 큰 다각형을 그리는 것보다 여러 개의 작은 다각형을 그리는 것이 일반적으로 더 빠르기 때문에 이 함수가 제공됩니다.
toFillPolygons() 함수는 경계 사각형이 겹치는 하위 경로에 대해서만 다각형을 생성한다는 점에서 toSubpathPolygons() 함수와 다릅니다.
toFillPolygon() 함수와 마찬가지로, 이 함수는 중복되는 서브패스가 올바른 채우기 규칙을 사용하여 채워지도록 보장하기 위해 되감기 기법을 사용합니다. 되감기 과정에서는 다각형 내에 추가 선분이 삽입되므로, 채워진 다각형의 윤곽선이 경로의 윤곽선과 일치하지 않는다는 점에 유의하십시오.
toSubpathPolygons(), toFillPolygon(), QPainterPath Conversion도 참조하십시오 .
QPainterPath QPainterPath::toReversed() const
경로의 순서가 반대로 된 복사본을 생성하여 반환합니다.
역순으로 바뀌는 것은 요소들의 순서입니다. 즉, QPainterPath 가 moveTo(), lineTo() 및 cubicTo() 함수를 지정된 순서대로 호출하여 구성된다면, 역순 복사본은 cubicTo(), lineTo() 및 moveTo()를 호출하여 구성됩니다.
QList<QPolygonF> QPainterPath::toSubpathPolygons(const QTransform &matrix = QTransform()) const
QTransform matrix 를 사용하여 경로를 다각형 목록으로 변환하고, 해당 목록을 반환합니다.
이 함수는 교차하는 하위 경로(즉, 경계 사각형이 겹치는 경우)와 관계없이 각 하위 경로마다 하나의 다각형을 생성합니다. 이러한 겹치는 하위 경로가 올바르게 채워지도록 하려면 대신 toFillPolygons() 함수를 사용하십시오.
toFillPolygons(), toFillPolygon() 및 QPainterPath Conversion도 참조하십시오 .
void QPainterPath::translate(qreal dx, qreal dy)
경로 내의 모든 요소를 (dx, dy)만큼 변환합니다.
translated()도 참조하십시오 .
void QPainterPath::translate(const QPointF &offset)
지정된 변환 offset 을 사용하여 경로 내의 모든 요소를 변환합니다.
이 함수는 오버로드된 함수입니다.
translated()도 참조하십시오 .
QPainterPath QPainterPath::translated(qreal dx, qreal dy) const
(dx, dy)에 의해 변환된 경로의 복사본을 반환합니다.
translate()도 참조하십시오 .
QPainterPath QPainterPath::translated(const QPointF &offset) const
주어진 ` offset`에 의해 변환된 경로의 복사본을 반환합니다.
이 함수는 오버로딩된 함수입니다.
translate()도 참조하십시오 .
[since 6.10] QPainterPath QPainterPath::trimmed(qreal fromFraction, qreal toFraction, qreal offset = 0) const
fromFraction 와 toFraction 사이의 길이를 차지하는 경로 구간을 반환합니다. 이 분수의 유효 범위는 경로의 시작점을 나타내는 0부터 끝점을 나타내는 1까지입니다. 이 분수 값은 백분율 t 값과 달리 경로 길이에 대해 선형적입니다.
offset 의 값은 분수 값에 더해집니다. 이로 인해 [0, 1] 범위를 초과하거나 미달하는 경우, 해당 값은 순환 처리되며 결과 경로도 마찬가지로 처리됩니다. 오프셋의 유효 범위는 -1과 1 사이입니다.
이 함수를 반복적으로 호출할 경우 {setCachingEnabled()}를 통해 캐싱을 활성화하여 최적화할 수 있습니다.
이 함수는 Qt 6.10에서 도입되었습니다.
length(), percentAtLength(), setCachingEnabled()도 참조하십시오 .
QPainterPath QPainterPath::united(const QPainterPath &p) const
이 경로의 채움 영역과 p 의 채움 영역을 합친 경로를 반환합니다.
경로에 대한 집합 연산은 경로를 영역으로 취급합니다. 닫히지 않은 경로는 암묵적으로 닫힌 것으로 간주됩니다. 베지어 곡선 교차 연산의 수치적 불안정성으로 인해 베지어 곡선이 선분으로 평탄화될 수 있습니다.
intersected() 및 subtracted()도 참조하십시오 .
bool QPainterPath::operator!=(const QPainterPath &path) const
이 페인터 경로가 지정된 경로( path)와 다를 경우 ` true `을 반환합니다.
경로를 비교하는 데는 요소별 비교가 포함될 수 있으며, 복잡한 경로의 경우 처리 속도가 느려질 수 있습니다.
operator==()도 참조하십시오 .
QPainterPath QPainterPath::operator&(const QPainterPath &other) const
이 경로와 other 경로의 교집합을 반환합니다.
intersected(), operator&=(), united(), operator|()도 참조하십시오 .
QPainterPath &QPainterPath::operator&=(const QPainterPath &other)
이 경로와 other 을 교차시키고, 이 경로에 대한 참조를 반환합니다.
intersected(), operator&(), operator|=()도 참조하십시오 .
QPainterPath QPainterPath::operator+(const QPainterPath &other) const
이 경로와 other 경로의 합집합을 반환합니다. 이 함수는 연산자 |()와 동일합니다.
united(), operator+=() 및 operator-()도 참조하십시오 .
QPainterPath &QPainterPath::operator+=(const QPainterPath &other)
이 경로를 other 와 병합하고, 이 경로에 대한 참조를 반환합니다. 이는 연산자 |=()와 동일합니다.
united(), operator+() 및 operator-=()도 참조하십시오 .
QPainterPath QPainterPath::operator-(const QPainterPath &other) const
이 경로의 복사본에서 other 경로를 빼고, 그 복사본을 반환합니다.
subtracted(), operator-=(), operator+()도 참조하십시오 .
QPainterPath &QPainterPath::operator-=(const QPainterPath &other)
이 경로에서 other 를 빼고, 이 경로에 대한 참조를 반환합니다.
subtracted(), operator-(), operator+=()도 참조하십시오 .
[noexcept] QPainterPath &QPainterPath::operator=(QPainterPath &&other)
other 를 이 QPainterPath 인스턴스에 할당합니다.
QPainterPath &QPainterPath::operator=(const QPainterPath &path)
지정된 path 를 이 페인터 경로에 할당합니다.
QPainterPath()도 참조하십시오 .
bool QPainterPath::operator==(const QPainterPath &path) const
이 페인터 경로(painterpath)가 지정된 경로( path)와 일치하면 ` true `를 반환합니다.
경로를 비교할 때는 요소별 비교가 필요할 수 있으며, 경로가 복잡한 경우 처리 속도가 느려질 수 있습니다.
operator!=()도 참조하십시오 .
QPainterPath QPainterPath::operator|(const QPainterPath &other) const
이 경로와 other 경로의 합집합을 반환합니다.
united(), operator|=(), intersected(), operator&()도 참조하십시오 .
QPainterPath &QPainterPath::operator|=(const QPainterPath &other)
이 경로를 ` other `와 결합하고, 이 경로에 대한 참조를 반환합니다.
united(), operator|(), operator&=()도 참조하십시오 .
관련 비회원
QDataStream &operator<<(QDataStream &stream, const QPainterPath &path)
지정된 페인터 path 를 지정된 stream 에 기록하고, stream 에 대한 참조를 반환합니다.
'Qt 데이터 유형 직렬화'항목도 참조하십시오 .
QDataStream &operator>>(QDataStream &stream, QPainterPath &path)
지정된 ` stream `에서 페인터 경로를 읽어 지정된 ` path`에 저장하고, ` stream`에 대한 참조를 반환합니다.
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.










