이 페이지에서

QCanvasGradient Class

QCanvasGradient는 모든 QCanvasPainter 그라데이션 브러시의 기본 클래스입니다. 더 보기...

헤더: #include <QCanvasGradient>
CMake: find_package(Qt6 REQUIRED COMPONENTS CanvasPainter)
target_link_libraries(mytarget PRIVATE Qt6::CanvasPainter)
이후 Qt 6.11
상속합니다: QCanvasBrush
에 의해 상속됨:

QCanvasBoxGradient, QCanvasConicalGradient, QCanvasLinearGradient, 및 QCanvasRadialGradient

상태: 기술 미리보기

공개 기능

QColor endColor() const
void setColorAt(float position, const QColor &color)
void setEndColor(const QColor &color)
void setStartColor(const QColor &color)
void setStops(const QCanvasGradientStops &stops)
QColor startColor() const
QCanvasGradientStops stops() const
QCanvasBrush::BrushType type() const
operator QVariant() const
QCanvasGradientStops
bool operator!=(const QCanvasGradient &lhs, const QCanvasGradient &rhs)
QDataStream &operator<<(QDataStream &stream, const QCanvasGradient &gradient)
QDataStream &operator<<(QDataStream &stream, const QCanvasGradientStop &stop)
bool operator==(const QCanvasGradient &lhs, const QCanvasGradient &rhs)
QDataStream &operator>>(QDataStream &stream, QCanvasGradient &gradient)
QDataStream &operator>>(QDataStream &stream, QCanvasGradientStop &stop)

상세 설명

QCanvasGradient는 모든 QCanvasPainter 그라데이션 브러시의 베이스 클래스입니다. 현재 네 가지 유형의 그라데이션이 있습니다: QCanvasLinearGradient, QCanvasRadialGradient, QCanvasConicalGradient, QCanvasBoxGradient 입니다.

setStartColor, setEndColor, setColorAt 또는 setStops 에 스톱이 제공되지 않으면 그래디언트는 시작 색상이 흰색(255,255,255)이고 끝 색상이 투명(0,0,0,0)으로 렌더링됩니다. 하나의 스톱만 제공되면 그라데이션이 이 색상으로 채워집니다.

QCanvasPainter 는 그라디언트 페인팅에 두 가지 다른 접근 방식을 사용합니다.

  • 최대 2 스톱을 사용하면 색상이 2개의 vec4 유니폼으로 셰이더에 전달됩니다. 따라서 2스톱 그라디언트 애니메이션을 매우 빠르게 처리할 수 있으며 그 사이에 추가 단계가 없습니다.
  • 2 스톱을 초과하면 색상이 셰이더에 1차원 텍스처로 전달됩니다. 기본적으로 텍스처 크기는 1x256픽셀로 품질과 성능에 최적화되어 있습니다. 텍스처는 캐시되므로 그라데이션 스톱이나 색상이 변경되지 않으면 다른 그라데이션 속성(위치, 각도 등)이 변경되더라도 이전 텍스처를 재사용할 수 있습니다. 멀티 스톱 그라디언트 애니메이션은 빠르지만 텍스처 업로드가 발생하므로 그만한 가치가 있는지 고려하세요.

그라디언트 텍스처 사용을 제어할 수 있는 환경 변수는 거의 없습니다:

  • QCPAINTER_DISABLE_TEXTURE_USAGE_TRACKING - 기본적으로 그라데이션 텍스처 사용량은 추적되어 최대량 이하로 유지됩니다. 이 환경 변수를 설정하면 트래킹을 비활성화하고 모든 그라데이션 텍스처를 메모리에 유지합니다.
  • QCPAINTER_MAX_TEXTURES - 기본적으로 텍스처의 최대 양은 1024 입니다. 원하는 최대 텍스처 양을 포함하도록 이 환경 변수를 설정합니다. 최대 양에 도달하면 현재 사용되지 않는 임시 그라데이션 텍스처는 자동으로 제거됩니다.

    참고: 텍스처 사용량 추적이 비활성화되어 있는 경우에는 이 기능이 적용되지 않습니다.

멤버 함수 문서

QColor QCanvasGradient::endColor() const

그라데이션 끝색 또는 가장 큰 위치의 색을 반환합니다. 끝 색이 설정되지 않은 경우 기본 끝 색인 투명한 검정색(0, 0, 0, 0)을 반환합니다.

setEndColor()도 참조하세요 .

void QCanvasGradient::setColorAt(float position, const QColor &color)

주어진 color 을 사용하여 주어진 position 에 정지 지점을 생성합니다. 주어진 position 은 0에서 1 범위여야 합니다.

setStops() 및 stops()도 참조하세요 .

void QCanvasGradient::setEndColor(const QColor &color)

그라데이션의 끝 색상을 color 로 설정합니다. 이는 위치 1 를 사용하여 setColorAt()를 호출하는 것과 같습니다.

endColor()도 참조하세요 .

void QCanvasGradient::setStartColor(const QColor &color)

그라데이션의 시작 색상을 color 로 설정합니다. 이는 위치 0 를 사용하여 setColorAt()를 호출하는 것과 같습니다.

startColor()도 참조하세요 .

void QCanvasGradient::setStops(const QCanvasGradientStops &stops)

현재 정지 지점 집합을 주어진 stops 으로 바꿉니다.

경유지 목록의 규칙은 다음과 같습니다:

  • 목록에는 최소 2개 이상의 정류장이 포함되어야 합니다.
  • 경유지 위치는 0~1 범위여야 하며, 가장 낮은 경유지부터 정렬해야 합니다.
  • 첫 번째 위치는 0.0, 마지막 위치는 1.0이어야 합니다.

setColorAt() 및 stops()도 참조하세요 .

QColor QCanvasGradient::startColor() const

그라데이션 시작 색 또는 가장 작은 위치의 색을 반환합니다. 시작 색이 설정되지 않은 경우 기본 시작 색인 흰색(255, 255, 255)을 반환합니다.

setStartColor()도 참조하세요 .

QCanvasGradientStops QCanvasGradient::stops() const

이 그라데이션의 정지점을 반환합니다.

setStops() 및 setColorAt()도 참조하세요 .

QCanvasBrush::BrushType QCanvasGradient::type() const

그라데이션 유형을 반환합니다.

QCanvasGradient::operator QVariant() const

그라데이션을 QVariant 로 반환합니다.

관련 비회원

QCanvasGradientStops

QList<QCanvasGradientStop>을 입력합니다.

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

그라데이션 lhsrhs 과 다르면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

operator==()도 참조하세요 .

QDataStream &operator<<(QDataStream &stream, const QCanvasGradient &gradient)

주어진 gradient 을 주어진 stream 에 쓰고 stream 에 대한 참조를 반환합니다.

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

QDataStream &operator<<(QDataStream &stream, const QCanvasGradientStop &stop)

주어진 stream 에 그라데이션 stop 을 쓰고 stream 에 대한 참조를 반환합니다.

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

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

그라데이션 lhsrhs 과 같으면 true 을 반환하고, 그렇지 않으면 false 을 반환합니다.

operator!=()도 참조하세요 .

QDataStream &operator>>(QDataStream &stream, QCanvasGradient &gradient)

주어진 stream 에서 주어진 gradient 을 읽고 stream 에 대한 참조를 반환합니다.

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

QDataStream &operator>>(QDataStream &stream, QCanvasGradientStop &stop)

주어진 stream 에서 그라데이션 stop 을 읽고 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.