QPainterPath Class

QPainterPath 클래스는 페인팅 작업을 위한 컨테이너를 제공하여 그래픽 도형을 구성하고 재사용할 수 있도록 합니다. 더 보기...

Header: #include <QPainterPath>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui

공용 유형

class Element
enum ElementType { MoveToElement, LineToElement, CurveToElement, CurveToDataElement }

공용 함수

QPainterPath()
QPainterPath(const QPointF &startPoint)
QPainterPath(const QPainterPath &path)
~QPainterPath()
void addEllipse(const QRectF &boundingRectangle)
void addEllipse(const QPointF &center, 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 &region)
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
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)
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
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()에서 경로의 시작 위치로 한 줄을 추가하여 현재 경로를 닫는 것입니다. 새 경로의 초기 currentPosition()는 (0, 0)이 됩니다.

QPainterPath 클래스는 또한 addEllipse(), addPath(), addRect(), addRegion() 및 addText() 등 페인터 경로에 닫힌 하위 경로를 추가하는 몇 가지 편의 함수를 제공합니다. addPolygon () 함수는 닫히지 않은 하위 경로를 추가합니다. 사실 이러한 함수는 모두 moveTo(), lineTo() 및 cubicTo() 작업의 모음입니다.

또한 connectPath() 함수를 사용하여 현재 경로에 경로를 추가할 수 있습니다. 그러나 이 함수는 현재 경로의 마지막 요소와 지정된 경로의 첫 번째 요소를 줄을 추가하여 연결한다는 점에 유의하세요.

아래는 QPainterPath 객체를 사용하는 방법을 보여주는 코드 스니펫입니다:

QPainterPath path;
path.addRect(20, 20, 60, 60);

path.moveTo(0, 0);
path.cubicTo(99, 0,  50, 50,  99, 99);
path.cubicTo(0, 99,  50, 50,  0, 0);

QPainter painter(this);
painter.fillRect(0, 0, 100, 100, Qt::white);
painter.setPen(QPen(QColor(79, 106, 25), 1, Qt::SolidLine,
                    Qt::FlatCap, Qt::MiterJoin));
painter.setBrush(QColor(122, 163, 39));

painter.drawPath(path);

페인터 경로는 처음 생성될 때 비어 있습니다. 먼저 닫힌 하위 경로인 직사각형을 추가합니다. 그런 다음 개별적으로 닫히지 않더라도 함께 닫힌 하위 경로를 형성하는 두 개의 베지어 곡선을 추가합니다. 마지막으로 전체 경로를 그립니다. 경로는 기본 채우기 규칙인 Qt::OddEvenFill 을 사용하여 채워집니다. Qt는 경로를 채우는 두 가지 방법을 제공합니다:

규칙의 정의는 Qt::FillRule 문서를 참조하십시오. 현재 설정된 페인터 경로의 채우기 규칙은 fillRule() 함수를 사용하여 검색하고 setFillRule() 함수를 사용하여 변경할 수 있습니다.

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의 예제 디렉토리에 있는 페인터 경로 예제와 벡터 변형 예제를 제공합니다.

페인터 경로 예제는 페인터 경로를 사용하여 렌더링할 복잡한 모양을 만드는 방법을 보여주며 사용자가 채우기 및 쓰다듬기를 실험해 볼 수 있습니다. 벡터 변형 예제는 QPainterPath를 사용하여 텍스트를 그리는 방법을 보여줍니다.

QPainterPathStroker, QPainter, QRegion, 및 페인터 경로 예시도참조하세요 .

멤버 유형 문서

enum QPainterPath::ElementType

이 열거형은 하위 경로에서 정점을 연결하는 데 사용되는 요소의 유형을 설명합니다.

addEllipse(), addPath(), addPolygon(), addRect(), addRegion() 및 addText() 편의 함수를 사용하여 닫힌 하위 경로로 추가된 요소는 실제로는 moveTo(), lineTo() 및 cubicTo() 함수를 사용하여 별도의 요소 모음으로 경로에 추가된다는 점에 유의하세요.

Constant설명
QPainterPath::MoveToElement0새 하위 경로입니다. moveTo ()도 참조하세요.
QPainterPath::LineToElement1줄입니다. lineTo ()도 참조하십시오.
QPainterPath::CurveToElement2커브. cubicTo () 및 quadTo()도 참조하십시오.
QPainterPath::CurveToDataElement3커브 요소에서 커브를 설명하는 데 필요한 추가 데이터입니다.

elementAt() 및 elementCount()도 참조하십시오 .

멤버 함수 문서

[noexcept] QPainterPath::QPainterPath()

빈 QPainterPath 객체를 생성합니다.

[explicit] QPainterPath::QPainterPath(const QPointF &startPoint)

주어진 startPoint 을 현재 위치로 하여 QPainterPath 객체를 생성합니다.

QPainterPath::QPainterPath(const QPainterPath &path)

주어진 path 의 복사본인 QPainterPath 객체를 만듭니다.

operator=()도 참조하십시오 .

[noexcept] QPainterPath::~QPainterPath()

QPainterPath 객체를 삭제합니다.

void QPainterPath::addEllipse(const QRectF &boundingRectangle)

지정된 boundingRectangle 내에 타원을 생성하고 닫힌 하위 경로로 페인터 경로에 추가합니다.

타원은 0도(3시 위치)에서 시작하고 끝나는 시계 방향 곡선으로 구성됩니다.

QLinearGradient myGradient;
QPen myPen;
QRectF boundingRectangle;

QPainterPath myPath;
myPath.addEllipse(boundingRectangle);

QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);

arcTo(), QPainter::drawEllipse() 및 Composing a QPainterPath참조하세요 .

void QPainterPath::addEllipse(const QPointF &center, qreal rx, qreal ry)

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

반지름이 rxrycenter 에 위치한 타원을 생성하고 페인터 경로에 닫힌 하위 경로로 추가합니다.

void QPainterPath::addEllipse(qreal x, qreal y, qreal width, qreal height)

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

(x, y), widthheight 에서 왼쪽 상단 모서리로 정의된 경계 사각형 내에 타원을 생성하여 닫힌 하위 경로로 페인터 경로에 추가합니다.

void QPainterPath::addPath(const QPainterPath &path)

주어진 path 경로에 닫힌 하위 경로로 추가합니다.

connectPath() 및 Composing a QPainterPath참조하세요 .

void QPainterPath::addPolygon(const QPolygonF &polygon)

주어진 polygon 을 경로에 (닫히지 않은) 하위 경로로 추가합니다.

다각형이 추가된 후의 현재 위치는 polygon 의 마지막 점입니다. 첫 번째 점으로 다시 선을 그리려면 closeSubpath() 함수를 사용합니다.

QLinearGradient myGradient;
QPen myPen;
QPolygonF myPolygon;

QPainterPath myPath;
myPath.addPolygon(myPolygon);

QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);

lineTo() 및 Composing a QPainterPath참조하세요 .

void QPainterPath::addRect(const QRectF &rectangle)

주어진 rectangle 을 이 경로에 닫힌 하위 경로로 추가합니다.

rectangle 은 시계 방향의 선 집합으로 추가됩니다. rectangle 추가 후 페인터 경로의 현재 위치는 직사각형의 왼쪽 상단 모서리에 있습니다.

QLinearGradient myGradient;
QPen myPen;
QRectF myRectangle;

QPainterPath myPath;
myPath.addRect(myRectangle);

QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);

addRegion(), lineTo() 및 Composing a QPainterPath참조하세요 .

void QPainterPath::addRect(qreal x, qreal y, qreal width, qreal height)

이 함수는 과부하된 함수입니다.

주어진 위치 (x, y)에 직사각형을 추가하고 widthheight 을 닫힌 하위 경로로 추가합니다.

void QPainterPath::addRegion(const QRegion &region)

영역의 각 사각형을 별도의 닫힌 하위 경로로 추가하여 주어진 region 을 경로에 추가합니다.

addRect() 및 Composing a QPainterPath참조하세요 .

void QPainterPath::addRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode = Qt::AbsoluteSize)

모서리가 둥근 주어진 직사각형 rect 을 경로에 추가합니다.

xRadiusyRadius 인수는 둥근 직사각형의 모서리를 정의하는 타원의 반지름을 지정합니다. modeQt::RelativeSize 인 경우 xRadiusyRadius 는 각각 직사각형 너비와 높이의 절반 비율로 지정되며 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)

제공된 font 에서 생성된 닫힌 하위 경로 집합으로 지정된 text 을 이 경로에 추가합니다. 하위 경로는 텍스트 기준선의 왼쪽 끝이 지정된 point 에 위치하도록 배치됩니다.

일부 글꼴은 겹치는 하위 경로를 생성할 수 있으며 올바른 렌더링을 위해 Qt::WindingFill 채우기 규칙이 필요합니다.

QLinearGradient myGradient;
QPen myPen;
QFont myFont;
QPointF baseline(x, y);

QPainterPath myPath;
myPath.addText(baseline, myFont, tr("Qt"));

QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);

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 을 차지하는 호 위에 놓인 위치로 이동을 생성합니다.

각도는 도 단위로 지정합니다. 시계 방향 호는 음의 각도를 사용하여 지정할 수 있습니다.

moveTo() 및 arcTo()도 참조하세요 .

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)

지정된 startAngle 에서 시작하여 시계 반대 방향으로 sweepLength 도 확장되는 지정된 rectangle 을 차지하는 호를 생성합니다.

각도는 도 단위로 지정합니다. 시계 방향 호는 음의 각도를 사용하여 지정할 수 있습니다.

이 함수는 호의 시작점과 현재 위치가 아직 연결되지 않은 경우 호의 시작점을 연결합니다. 호가 추가되면 현재 위치가 호의 마지막 지점이 됩니다. 첫 번째 점으로 다시 선을 그리려면 closeSubpath() 함수를 사용합니다.

QPainterPath myPath;
myPath.moveTo(center);
myPath.arcTo(boundingRect, startAngle,
             sweepLength);

QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);

arcMoveTo(), addEllipse(), QPainter::drawArc(), QPainter::drawPie() 및 Composing a QPainterPath참조하세요 .

void QPainterPath::arcTo(qreal x, qreal y, qreal width, qreal height, qreal startAngle, qreal sweepLength)

이 함수는 과부하된 함수입니다.

지정된 startAngle 에서 시작하여 시계 반대 방향으로 sweepLength 도 확장되는 직사각형 QRectF(x, y, width, height)을 채우는 호를 생성합니다.

QRectF QPainterPath::boundingRect() const

이 페인터 경로의 경계 사각형을 부동 소수점 정밀도의 직사각형으로 반환합니다.

controlPointRect()도 참조하십시오 .

int QPainterPath::capacity() const

QPainterPath 에 할당된 요소의 수를 반환합니다.

clear() 및 reserve()도 참조하세요 .

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)

c1c2 에서 지정한 제어점을 사용하여 현재 위치와 지정된 endPoint 사이에 큐빅 베지어 커브를 추가합니다.

커브가 추가되면 현재 위치가 커브의 끝점이 되도록 업데이트됩니다.

QLinearGradient myGradient;
QPen myPen;

QPainterPath myPath;
myPath.cubicTo(c1, c2, endPoint);

QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);

quadTo() 및 Composing a QPainterPath도 참조하세요 .

void QPainterPath::cubicTo(qreal c1X, qreal c1Y, qreal c2X, qreal c2Y, qreal endPointX, qreal endPointY)

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

(c1X, c1Y) 및 (c2X, c2Y)로 지정된 제어점을 사용하여 현재 위치와 끝점 (endPointX, endPointY) 사이에 큐빅 베지어 커브를 추가합니다.

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()도 참조하세요 .

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)

c 으로 지정된 제어점을 사용하여 현재 위치와 지정된 endPoint 사이에 이차 베지어 곡선을 추가합니다.

커브가 추가되면 현재 지점이 커브의 끝점이 되도록 업데이트됩니다.

cubicTo() 및 Composing a QPainterPath도 참조하세요 .

void QPainterPath::quadTo(qreal cx, qreal cy, qreal endPointX, qreal endPointY)

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

(cx, cy)로 지정된 제어점을 사용하여 현재 점과 끝점(endPointX, endPointY) 사이에 이차 베지어 곡선을 추가합니다.

void QPainterPath::reserve(int size)

QPainterPath 의 내부 메모리에 지정된 양의 요소를 예약합니다.

최소 size 요소에 대한 메모리 할당을 시도합니다.

clear(), capacity() 및 QList::reserve()도 참조하세요 .

void QPainterPath::setElementPositionAt(int index, qreal x, qreal y)

인덱스 index 에 있는 요소의 x 및 y 좌표를 xy 로 설정합니다.

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 을 사용하여 경로를 다각형으로 변환하고 다각형을 반환합니다.

다각형은 먼저 모든 하위 경로를 다각형으로 변환한 다음 되감기 기술을 사용하여 겹치는 하위 경로가 올바른 채우기 규칙을 사용하여 채워질 수 있는지 확인하여 만들어집니다.

되감기하면 다각형에 추가 선이 삽입되므로 채우기 다각형의 윤곽이 경로의 윤곽과 일치하지 않습니다.

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

경로의 반전된 복사본을 생성하고 반환합니다.

moveTo(), lineTo(), cubicTo() 함수를 지정된 순서대로 호출하여 QPainterPath 를 구성하는 경우, 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()도 참조하세요 .

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

이 페인터 경로가 주어진 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 데이터 유형 직렬화도참조하십시오 .

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