이 페이지에서

QCanvasPath Class

QCanvasPath는 QCanvasPainter 의 기본 경로 형식입니다. 더 보기...

헤더: #include <QCanvasPath>
CMake: find_package(Qt6 REQUIRED COMPONENTS CanvasPainter)
target_link_libraries(mytarget PRIVATE Qt6::CanvasPainter)
다음부터: Qt 6.11부터

공개 함수

QCanvasPath()
QCanvasPath(qsizetype commandsSize, qsizetype commandsDataSize = -1)
QCanvasPath(const QCanvasPath &path)
QCanvasPath(QCanvasPath &&other)
~QCanvasPath()
(since 6.12) void addPath(QStringView svgPath, const QTransform &transform = QTransform())
void addPath(const QCanvasPath &path, const QTransform &transform = QTransform())
void addPath(const QCanvasPath &path, qsizetype start, qsizetype count, const QTransform &transform = QTransform())
void arc(qreal centerX, qreal centerY, qreal radius, qreal a0, qreal a1, QCanvasPainter::PathWinding direction = QCanvasPainter::PathWinding::ClockWise, QCanvasPainter::PathConnection connection = QCanvasPainter::PathConnection::Connected)
void arc(QPointF centerPoint, qreal radius, qreal a0, qreal a1, QCanvasPainter::PathWinding direction = QCanvasPainter::PathWinding::ClockWise, QCanvasPainter::PathConnection connection = QCanvasPainter::PathConnection::Connected)
void arcTo(qreal x1, qreal y1, qreal x2, qreal y2, qreal radius)
void arcTo(QPointF point1, QPointF point2, qreal radius)
void beginHoleSubPath()
void beginSolidSubPath()
void bezierCurveTo(qreal cp1X, qreal cp1Y, qreal cp2X, qreal cp2Y, qreal x, qreal y)
void bezierCurveTo(QPointF controlPoint1, QPointF controlPoint2, QPointF endPoint)
void circle(qreal x, qreal y, qreal radius)
void circle(QPointF centerPoint, qreal radius)
void clear()
void closePath()
qsizetype commandsCapacity() const
qsizetype commandsDataCapacity() const
qsizetype commandsDataSize() const
qsizetype commandsSize() const
QPointF currentPosition() const
void ellipse(qreal x, qreal y, qreal radiusX, qreal radiusY)
void ellipse(const QRectF &rect)
bool isEmpty() const
void lineTo(QPointF point)
void lineTo(qreal x, qreal y)
void moveTo(QPointF point)
void moveTo(qreal x, qreal y)
QPointF positionAt(qsizetype index) const
void quadraticCurveTo(qreal cpX, qreal cpY, qreal x, qreal y)
void quadraticCurveTo(QPointF controlPoint, QPointF endPoint)
void rect(qreal x, qreal y, qreal width, qreal height)
void rect(const QRectF &rect)
void reserve(qsizetype commandsSize, qsizetype commandsDataSize = -1)
void roundRect(qreal x, qreal y, qreal width, qreal height, qreal radius)
void roundRect(qreal x, qreal y, qreal width, qreal height, qreal radiusTopLeft, qreal radiusTopRight, qreal radiusBottomRight, qreal radiusBottomLeft)
void roundRect(const QRectF &rect, qreal radius)
void roundRect(const QRectF &rect, qreal radiusTopLeft, qreal radiusTopRight, qreal radiusBottomRight, qreal radiusBottomLeft)
void setPathWinding(QCanvasPainter::PathWinding winding)
QCanvasPath sliced(qsizetype start, qsizetype count, const QTransform &transform = QTransform()) const
void squeeze()
void swap(QCanvasPath &other)
operator QVariant() const
QCanvasPath &operator=(QCanvasPath &&other)
QCanvasPath &operator=(const QCanvasPath &path)
bool operator!=(const QCanvasPath &lhs, const QCanvasPath &rhs)
bool operator==(const QCanvasPath &lhs, const QCanvasPath &rhs)

상세 설명

페인터 경로는 직사각형, 타원, 선, 곡선 등 여러 그래픽 구성 요소로 이루어진 객체입니다. QCanvasPath API는 QCanvasPainter 의 경로 페인팅과 호환되므로, 직접 페인팅과 경로 내 페인팅 간에 코드를 쉽게 조정할 수 있습니다. QCanvasPath를 사용하는 주된 이유는 렌더링의 모든 프레임에서 사용되는 정적 경로를 다시 생성하는 것을 피하고, 경로가 채워지거나 획이 그려질 때마다 데이터를 재생성하는 대신 경로 관련 렌더링 데이터(예: 경로에서 생성된 정점 및 인덱스 데이터)를 캐싱할 수 있도록 하기 위함입니다.

QPainterPath 와 비교했을 때, QCanvasPath는 경로를 비교하거나 조정하는 기능이 더 적지만 렌더링에 더 최적화되어 있습니다. 특히:

  • 두 경로 간의 교차 또는 차집합을 처리하는 메서드는 없습니다.
  • 경로를 이동시키는 메서드가 없습니다.
  • 텍스트를 추가하는 메서드가 없습니다.

기능적인 관점에서 볼 때, QCanvasPath는 HTML Canvas Path2D와 더 유사하며, 일부 기능이 추가되었고 API는 QCanvasPainter 와 일치합니다.

경로 그룹 및 캐싱

QCanvasPath를 통해 경로를 그릴 경우, 엔진이 경로 지오메트리(정점)를 캐싱할 수 있습니다. 이는 정적 경로의 성능을 향상시키지만, CPU 및 GPU 메모리 소비를 증가시킬 가능성이 있습니다.

QCanvasPath 를 매개변수로 받는 fill() 또는 stroke()를 사용하여 경로를 그릴 때, 두 번째 매개변수로 pathGroup 를 설정할 수 있습니다.

기본적으로 pathGroup 는 -1 로 설정되어 있어, 경로 데이터가 캐시되지 않으므로 렌더링은 beginPath()를 사용하여 직접 페인팅한 다음 경로 정의 명령을 실행하고, 마지막으로 채우기나 획을 그리는 경우와 거의 동일하게 진행됩니다.

pathGroup 를 0 또는 그 이상의 값으로 설정하면 경로에서 생성된 지오메트리의 캐싱 및 재사용이 활성화됩니다. 경로를 경로 그룹으로 구성하면 렌더링 성능과 메모리 사용량을 효율적으로 최적화할 수 있습니다. 서로 관련이 있고 종종 동시에 변경되는 경로는 최적의 결과를 얻기 위해 동일한 그룹에 포함되어야 합니다.

경로가 변경되면, 해당 데이터는 캐시에 저장되어 있었더라도 자동으로 업데이트됩니다. 경로 그룹의 지오메트리 업데이트를 유발하는 요인은 다음과 같습니다:

상태 변환(QCanvasPainter::transform(), QCanvasPainter::rotate() 등)을 변경해도 경로가 무효화되지 않으므로, 캐시된 경로를 이동/확대/축소/회전하는 작업은 매우 효율적입니다.

예를 들어, 매우 많은 수의 명령이 포함된 QCanvasPath p 를 생각해 보겠습니다. 이 경로를 p 로 획을 그리거나 채우는 작업은 CPU 측에서 수행되는 작업량 때문에 비용이 많이 드는 작업이 될 수 있습니다. 각 프레임마다 이러한 스트로크 또는 채우기 작업이 수행될 때마다 정점 데이터가 재생성되어 GPU 버퍼로 업로드될 수 있습니다. 경로가 고정되어 있고, 매 프레임마다 가능한 한 효율적으로 경로를 반복해서 그리기만 원하는 경우에는 이는 이상적인 방식이 아닙니다.

경로 그룹이 지정된 경우(예: stroke(p) 을 stroke(p, 5) 로 대체), 렌더러는 경로 p 및 스트로크나 채우기 명령에 동일한 그룹(5)이 지정된 다른 모든 경로에 대해 전용 정점 및 인덱스 버퍼를 유지할 수 있습니다.

경로 p (QCanvasPath 내의 명령어)가 변경되지 않는다고 가정하면, 이 경로를 반복적으로 채우거나 스트로크하는 작업은 비용이 적게 드는 작업이 됩니다. 이는 경로 그룹 5 전용 GPU 버퍼에 모든 데이터가 이미 존재하기 때문입니다. 변환 작업 역시 비용이 적게 듭니다. 캐시된 경로 그룹을 사용하면 변환이 지오메트리 자체에서가 아니라 버텍스 셰이더에서 이루어지기 때문입니다.

다음 코드 예시에서, m_path 가 충분히 복잡하여 명령어가 변경되지 않고 매 프레임마다 동일한 획 너비, 앤티앨리어싱 수준 등으로 획이 그려진다면, 다음 코드는 경로 그룹을 사용하지 않는 경우보다 훨씬 더 효율적일 수 있습니다:

// m_path is QCanvasPath with lots of commands in it
const int pathGroup = 5;

// in every frame:
  painter->stroke(m_path, pathGroup);
  // ... other draw commands
  painter->translate(100, 0);
  painter->stroke(m_path, pathGroup);
  // ... other draw commands

m_path 를 두 번째, 세 번째 및 그 이후에 그릴 때, CPU 측에서 경로 지오메트리 처리가 필요하지 않기 때문에 경로 그룹을 사용하지 않는 경우에 비해 렌더링 비용이 매우 낮아집니다. 평행 이동을 적용하여 변환을 변경해도 캐시된 경로 그룹 데이터가 무효화되지 않으므로, 변환된 stroke() 호출도 마찬가지로 빠릅니다.

위에서 언급한 관련 상태 중 하나가 변경되면 어떻게 될까요? 예를 들어, 경로가 두 가지 다른 획 두께로 그려진 경우:

// m_path is QCanvasPath with lots of commands in it
const int pathGroup = 5;

// in every frame:
  painter->setStrokeWidth(4);
  painter->stroke(m_path, pathGroup);
  // ... other draw commands
  painter->translate(100, 0);
  painter->setStrokeWidth(8);
  painter->stroke(m_path, pathGroup);
  // ... other draw commands

이 경우에도 경로 정점 데이터가 캐시되어 획 두께 4와 8 모두에 재사용되므로 여전히 매우 효율적이지만, 경로 그룹 5 의 GPU 버퍼에 획 두께 4와 8 버전의 경로 지오메트리가 모두 포함되므로 리소스 사용량은 약간 증가합니다.

경로 그룹을 이해하는 한 가지 방법은 이를 캐싱 메커니즘으로 보는 것입니다. 이때 경로 그룹 값은 1단계 캐시 키로 취급되며, QCanvasPath 객체, 앤티앨리어싱 정도, 렌더링 힌트, 그리고 획을 그릴 경우 획 두께, 선 끝 모양, 선 연결 방식이 2단계 캐시 키를 구성합니다 (경로 그룹 내에서)를 구성합니다.

경로 명령(QCanvasPath 내의 요소)을 변경하는 것은 항상 비용이 많이 듭니다. 이는 CPU 및 GPU 측에서 관련 데이터를 항상 재구축해야 하기 때문입니다. 다소 극단적인 예로, QCanvasPath가 매 프레임마다 명령을 변경하는 경우, QCanvasPainter 함수를 통한 직접적인 경로 그리기에 비해 이점이 없으므로 해당 경로에 대해 경로 그룹(심지어 QCanvasPath조차도)을 사용하는 것은 무의미합니다.

더 이상 그리기 작업에서 경로 그룹을 사용하지 않거나, 애플리케이션이 가능한 한 메모리를 확보하고자 하는 경우, QCanvasPainter::removePathGroup()를 호출하여 캐시를 해제할 수 있습니다. 캐시된 경로는 페인터의 소멸자(destructor) 실행 중에 자동으로 해제되므로, 일반적으로 이 작업은 필요하지 않습니다.

QCanvasPainter::addPath() 및 QCanvasPainter::removePathGroup()도 참조하십시오 .

멤버 함수 문서

QCanvasPath::QCanvasPath()

빈 경로를 생성합니다.

[explicit] QCanvasPath::QCanvasPath(qsizetype commandsSize, qsizetype commandsDataSize = -1)

빈 경로를 생성하며, commandsSize 개수의 명령어와 선택적으로 commandsDataSize 개수의 데이터에 대한 공간을 할당합니다. commandsDataSize 매개변수가 지정되지 않으면, 2 * commandsSize 개수의 데이터에 대한 공간이 자동으로 예약되는데, 이는 경로 명령어가 직선(moveTo(), lineTo(), rect())일 때 최적의 양입니다.

적절한 공간을 확보하는 것은 경로 생성 및 메모리 사용에 대한 최적화입니다. 경로에 명령을 추가하는 동안 충분한 공간이 자동으로 확보되므로, 이는 필수 사항은 아닙니다.

reserve()도 참조하십시오 .

QCanvasPath::QCanvasPath(const QCanvasPath &path)

주어진 ` path`의 복사본인 경로를 생성합니다.

[noexcept] QCanvasPath::QCanvasPath(QCanvasPath &&other)

other 에서 새로운 QCanvasPath를 생성합니다.

[noexcept] QCanvasPath::~QCanvasPath()

경로를 삭제합니다.

[since 6.12] void QCanvasPath::addPath(QStringView svgPath, const QTransform &transform = QTransform())

이 경로에 ` svgPath `를 추가하며, 선택적으로 ` transform `를 사용하여 경로 지점을 수정할 수 있습니다. 경로의 예상 크기가 알려진 경우, 이 작업 전에 ` reserve()`를 호출하는 것을 고려해 보십시오.

SVG 경로에서 생성된 똑같은 녹색 곡선 두 개로, 두 번째는 첫 번째를 이동시킨 복사본입니다.
// m_path is QCanvasPath
if (m_path.isEmpty()) {
    QString path("M 20 20 C 40 120, 80 120, 100 20 Z");
    m_path.addPath(path);
    m_path.addPath(path, QTransform::fromTranslate(80, 80));
}
p->fill(m_path);
p->stroke(m_path);

이 형식에 대한 자세한 내용은 W3C SVG 경로 데이터를 참조하십시오.

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

void QCanvasPath::addPath(const QCanvasPath &path, const QTransform &transform = QTransform())

이 경로에 ` path `을 추가하며, 선택적으로 ` transform `을 사용하여 경로 지점을 변경할 수 있습니다. ` transform `이 지정되지 않았거나(또는 단위 행렬인 경우), 이 연산은 경로 데이터를 재사용하므로 매우 빠르게 수행됩니다.

void QCanvasPath::addPath(const QCanvasPath &path, qsizetype start, qsizetype count, const QTransform &transform = QTransform())

start 에 있는 명령어부터 시작하여, count 만큼의 명령어를 포함하여 path 를 현재 경로에 추가합니다. 선택적으로 transform 를 사용하여 경로 지점을 변경할 수 있습니다. start 와 count 의 범위가 확인되므로, QCanvasPath::commandsSize()보다 더 많은 명령어에 접근하지 않습니다. 경로가 현재 경로 위치에서 이어지지 않아야 하는 경우, 먼저 path.positionAt(start - 1) 를 인수로 지정하여 moveTo()를 호출하십시오.

void QCanvasPath::arc(qreal centerX, qreal centerY, qreal radius, qreal a0, qreal a1, QCanvasPainter::PathWinding direction = QCanvasPainter::PathWinding::ClockWise, QCanvasPainter::PathConnection connection = QCanvasPainter::PathConnection::Connected)

QPointF(centerX, centerY)를 중심으로, 주어진 radius 를 사용하여 a0 라디안의 각도에서 시작하여 a1 라디안의 각도에서 끝나는 호를 생성합니다. 이 호는 주어진 direction 를 가로지릅니다. connection 가 NotConnected 일 경우, 이전 경로는 닫히고 새로운 하위 경로가 시작됩니다.

void QCanvasPath::arc(QPointF centerPoint, qreal radius, qreal a0, qreal a1, QCanvasPainter::PathWinding direction = QCanvasPainter::PathWinding::ClockWise, QCanvasPainter::PathConnection connection = QCanvasPainter::PathConnection::Connected)

centerPoint 를 중심으로, 주어진 radius 를 사용하여 a0 라디안의 각도에서 시작하여 a1 라디안에서 끝나는 호를 생성합니다. 이 호는 주어진 direction 를 가로지릅니다. connection 가 NotConnected 일 때, 이전 경로는 닫히고 새로운 하위 경로가 시작됩니다.

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

void QCanvasPath::arcTo(qreal x1, qreal y1, qreal x2, qreal y2, qreal radius)

QPointF(x1, y1) 및 QPointF(x2, y2) 지점을 사용하여, 주어진 radius 값으로 호를 생성합니다.

void QCanvasPath::arcTo(QPointF point1, QPointF point2, qreal radius)

point1 및 point2 좌표를 사용하여, 주어진 radius 값으로 호를 생성합니다.

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

void QCanvasPath::beginHoleSubPath()

홀 서브 경로를 시작합니다. 이는 ` setPathWinding(QCanvasPainter::PathWinding::ClockWise))`과 동일합니다.

beginSolidSubPath()도 참조하십시오 .

void QCanvasPath::beginSolidSubPath()

고체 서브패스를 시작합니다. 이는 setPathWinding(QCanvasPainter::PathWinding::CounterClockWise))와 동일합니다.

beginHoleSubPath()도 참조하십시오 .

void QCanvasPath::bezierCurveTo(qreal cp1X, qreal cp1Y, qreal cp2X, qreal cp2Y, qreal x, qreal y)

cp1X, cp1Y, cp2X, cp2Y 로 지정된 제어점을 사용하여, 현재 위치와 x 및 y 로 지정된 종점 사이에 3차 베지어 곡선을 추가합니다.

곡선이 추가된 후, 현재 위치는 곡선의 끝점에 오도록 업데이트됩니다.

void QCanvasPath::bezierCurveTo(QPointF controlPoint1, QPointF controlPoint2, QPointF endPoint)

controlPoint1 와 controlPoint2 에서 지정한 제어점을 사용하여, 현재 위치와 지정된 endPoint 사이에 3차 베지어 곡선을 추가합니다.

곡선이 추가된 후, 현재 위치는 곡선의 끝점에 오도록 업데이트됩니다.

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

void QCanvasPath::circle(qreal x, qreal y, qreal radius)

QPointF(x, y)를 중심으로 하고, 지정된 radius 를 가진 원을 경로에 추가합니다.

void QCanvasPath::circle(QPointF centerPoint, qreal radius)

centerPoint 를 중심으로 하고, 지정된 radius 를 반지름으로 하는 원을 경로에 추가합니다.

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

void QCanvasPath::clear()

경로 명령어와 데이터를 지웁니다.

경로 명령어가 변경되어 경로를 다시 생성해야 할 때 이 함수를 호출하십시오. 이 함수는 메모리 사용량에 영향을 미치지 않으므로, 메모리 사용량 관리를 위해서는 reserve() 및 squeeze()를 사용하십시오.

reserve() 및 squeeze()도 참조하십시오 .

void QCanvasPath::closePath()

현재 하위 경로의 시작 지점까지 선을 그려 해당 하위 경로를 닫고, 자동으로 새로운 경로를 시작합니다.

qsizetype QCanvasPath::commandsCapacity() const

경로에 있는 명령어의 용량을 반환합니다.

commandsDataCapacity() 및 reserve()도 참조하십시오 .

qsizetype QCanvasPath::commandsDataCapacity() const

지정된 경로에 있는 commands 데이터의 용량을 반환합니다.

commandsCapacity() 및 reserve()도 참조하십시오 .

qsizetype QCanvasPath::commandsDataSize() const

경로에 포함된 명령 데이터의 양을 반환합니다.

명령 데이터란 기본적으로 명령을 실행하는 데 필요한 포인트를 의미합니다.

참고: 일부 경로 요소는 여러 개의 데이터 포인트를 필요로 합니다. 예를 들어, ` closePath `는 ` 0`을 필요로 하며, ` moveTo `와 ` lineTo `는 ` 2`을, ` bezierCurveTo `는 6개를, ` roundRect `는 ` 34 ` 데이터 포인트를 필요로 합니다.

qsizetype QCanvasPath::commandsSize() const

경로에 포함된 명령어의 수를 반환합니다.

참고: 일부 경로 요소에는 여러 개의 명령이 필요합니다. 예를 들어, moveTo 및 lineTo 에는 1 개의 명령이 필요하고, bezierCurveTo 에는 6 개의 명령이 필요하며, roundRect 에는 10 개의 명령이 필요합니다.

QPointF QCanvasPath::currentPosition() const

경로의 현재 위치를 반환합니다. 이는 이전 경로 명령어(moveTo, lineTo, bezierCurveTo 등)가 종료된 위치를 의미합니다. 경로가 비어 있을 경우 (0.0, 0.0)을 반환합니다.

void QCanvasPath::ellipse(qreal x, qreal y, qreal radiusX, qreal radiusY)

(x, y)를 중심으로, 반지름이 radiusX, radiusY 로 정의된 타원을 생성하고, 이를 닫힌 하위 경로로 경로에 추가합니다.

void QCanvasPath::ellipse(const QRectF &rect)

rect 사각형 내에 타원을 생성하고, 이를 닫힌 하위 경로로 경로에 추가합니다.

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

bool QCanvasPath::isEmpty() const

경로가 비어 있을 때 true를 반환합니다.

clear도 참조하십시오 .

void QCanvasPath::lineTo(QPointF point)

현재 위치에서 지정된 좌표 point 까지 직선을 그립니다. 선이 그려진 후, 현재 위치는 선의 끝점 위치로 업데이트됩니다.

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

void QCanvasPath::lineTo(qreal x, qreal y)

현재 위치에서 점 (x, y)까지 선을 그립니다.

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

void QCanvasPath::moveTo(QPointF point)

현재 지점을 지정된 point 로 이동하며, 암시적으로 새로운 하위 경로를 시작하고 이전 경로를 닫습니다.

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

void QCanvasPath::moveTo(qreal x, qreal y)

현재 위치를 (x, y)로 이동하고 새로운 하위 경로를 시작하며, 이전 경로는 암시적으로 닫습니다.

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

QPointF QCanvasPath::positionAt(qsizetype index) const

index 에서 경로의 위치를 반환합니다. 이는 index 에서 path 명령어(moveTo, lineTo, bezierCurveTo 등)가 위치한 위치를 의미합니다. 인덱스는 0 과 commandsSize() - 1 사이여야 합니다. 경로가 비어 있을 경우 (0.0, 0.0)을 반환합니다.

void QCanvasPath::quadraticCurveTo(qreal cpX, qreal cpY, qreal x, qreal y)

현재 점과 끝점(x, y) 사이에, (cpX, cpY)로 지정된 제어점을 갖는 2차 베지어 곡선을 추가합니다.

void QCanvasPath::quadraticCurveTo(QPointF controlPoint, QPointF endPoint)

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

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

void QCanvasPath::rect(qreal x, qreal y, qreal width, qreal height)

QPointF(x, y) 위치에, 지정된 width 및 height 값을 가진 사각형을 생성합니다.

void QCanvasPath::rect(const QRectF &rect)

다음으로 지정된 사각형을 생성합니다. rect

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

void QCanvasPath::reserve(qsizetype commandsSize, qsizetype commandsDataSize = -1)

QCanvasPath 의 내부 메모리에서 지정된 양의 공간을 할당합니다.

최소 commandsSize 개의 명령어와 commandsDataSize 개의 데이터 포인트에 대한 메모리를 할당하려고 시도합니다. 일부 경로 요소는 여러 개의 명령어를 필요로 하므로, commandsSize() 및 commandsDataSize()를 참조하십시오.

commandsDataSize 가 지정되지 않은 경우, 2 * commandsSize 의 데이터 양에 대한 공간이 자동으로 예약되며, 이는 경로 명령어가 직선일 때(moveTo(), lineTo(), rect())의 최적 양입니다.

적절한 공간을 확보하는 것은 경로 생성 및 메모리 사용량을 최적화하기 위한 조치입니다. 경로에 명령을 추가하는 과정에서 충분한 공간이 자동으로 확보되므로, 반드시 지정해야 하는 것은 아닙니다.

squeeze(), commandsCapacity() 및 commandsDataCapacity()도 참조하십시오 .

void QCanvasPath::roundRect(qreal x, qreal y, qreal width, qreal height, qreal radius)

지정된 직사각형 x, y, width, height 을 모서리가 둥근 형태로 경로에 추가합니다. 모서리는 지정된 radius 값을 가진 1/4 원으로 처리됩니다.

void QCanvasPath::roundRect(qreal x, qreal y, qreal width, qreal height, qreal radiusTopLeft, qreal radiusTopRight, qreal radiusBottomRight, qreal radiusBottomLeft)

모서리가 둥근 사각형 x, y, width, height 을 경로에 추가합니다. 모서리는 각각 반지름 radiusTopLeft, radiusTopRight, radiusBottomRight, radiusBottomLeft 인 1/4원입니다.

void QCanvasPath::roundRect(const QRectF &rect, qreal radius)

지정된 직사각형 rect 의 모서리를 둥글게 처리하여 경로에 추가합니다. 모서리는 지정된 반지름 radius 을 가진 1/4원 모양입니다.

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

void QCanvasPath::roundRect(const QRectF &rect, qreal radiusTopLeft, qreal radiusTopRight, qreal radiusBottomRight, qreal radiusBottomLeft)

모서리가 둥근 사각형 rect 을 경로에 추가합니다. 모서리는 각각 반지름 radiusTopLeft, radiusTopRight, radiusBottomRight, radiusBottomLeft 인 1/4 원으로 구성됩니다.

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

void QCanvasPath::setPathWinding(QCanvasPainter::PathWinding winding)

현재 서브 경로 winding 를 QCanvasPainter::CounterClockWise (기본값) 또는 QCanvasPainter::ClockWise 중 하나로 설정합니다. CounterClockWise는 채워진 서브 경로를 그리고, ClockWise는 구멍을 그립니다.

참고: 이 명령은 lineTo, moveTo 등과 유사한 명령이므로, 변경된 회전 방향을 적용할 나머지 명령들을 실행하기 전에 회전 방향 설정을 먼저 완료해야 합니다.

QCanvasPath QCanvasPath::sliced(qsizetype start, qsizetype count, const QTransform &transform = QTransform()) const

이 경로의 명령어를 포함하는 새로운 경로를 반환하며, start 에 있는 명령어부터 시작하여 count 개수의 명령어를 포함하고, 선택적으로 transform 를 사용하여 경로 지점을 변경할 수 있습니다.

start 과 count 의 범위가 확인되어, commandsSize()보다 더 많은 명령에 접근하지 않도록 합니다. start 에 있는 명령이 MoveTo 가 아닌 경우, 이 슬라이스가 독립적인 경로가 되도록 첫 번째 명령이 MoveTo 로 대체됩니다.

void QCanvasPath::squeeze()

경로 명령어와 데이터를 저장하는 데 필요하지 않은 메모리를 해제합니다. 이 함수는 reserve()를 호출한 후 메모리 사용량을 줄이는 데 사용할 수 있습니다.

일반적으로 이 함수를 사용할 필요는 없지만, 많은 요소를 예약하거나 추가(lineTo, bezierCurveTo 등)하여 경로 크기가 커진 경우, 향후 크기가 훨씬 작아질 것으로 예상된다면 먼저 reserve() 를 호출한 다음 squeeze() 를 호출하여 일부 메모리를 해제할 수 있습니다.

reserve()도 참조하십시오 .

[noexcept] void QCanvasPath::swap(QCanvasPath &other)

이 경로를 ` other`로 바꿉니다. 이 작업은 매우 빠르며 절대 실패하지 않습니다.

QCanvasPath::operator QVariant() const

경로를 ` QVariant` 형식으로 반환합니다.

[noexcept] QCanvasPath &QCanvasPath::operator=(QCanvasPath &&other)

other 를 이 QCanvasPath 인스턴스에 할당합니다.

QCanvasPath &QCanvasPath::operator=(const QCanvasPath &path)

지정된 path 를 이 경로에 할당하고, 이 경로에 대한 참조를 반환합니다.

관련 비멤버

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

lhs 경로가 rhs 과 다를 경우 true 을 반환하고, 그렇지 않은 경우 false 을 반환합니다.

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

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

lhs 경로가 rhs 과 동일한 경우 true 을 반환하고, 그렇지 않은 경우 false 을 반환합니다.

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

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