QLegend Class

QLegend 클래스는 차트의 범례를 표시합니다. 더 보기...

Header: #include <QLegend>
In QML: Legend
Inherits: QGraphicsWidget

공용 유형

enum MarkerShape { MarkerShapeDefault, MarkerShapeRectangle, MarkerShapeCircle, MarkerShapeRotatedRectangle, MarkerShapeTriangle, …, MarkerShapeFromSeries }

속성

공공 기능

virtual ~QLegend()
Qt::Alignment alignment() const
void attachToChart()
QColor borderColor()
QBrush brush() const
QColor color()
void detachFromChart()
QFont font() const
bool isAttachedToChart()
bool isBackgroundVisible() const
(since 6.2) bool isInteractive() const
QBrush labelBrush() const
QColor labelColor() const
QLegend::MarkerShape markerShape() const
QList<QLegendMarker *> markers(QAbstractSeries *series = nullptr) const
QPen pen() const
bool reverseMarkers()
void setAlignment(Qt::Alignment alignment)
void setBackgroundVisible(bool visible = true)
void setBorderColor(QColor color)
void setBrush(const QBrush &brush)
void setColor(QColor color)
void setFont(const QFont &font)
(since 6.2) void setInteractive(bool interactive)
void setLabelBrush(const QBrush &brush)
void setLabelColor(QColor color)
void setMarkerShape(QLegend::MarkerShape shape)
void setPen(const QPen &pen)
void setReverseMarkers(bool reverseMarkers = true)
void setShowToolTips(bool show)
bool showToolTips() const

신호

(since 6.2) void attachedToChartChanged(bool attached)
void backgroundVisibleChanged(bool visible)
void borderColorChanged(QColor color)
void colorChanged(QColor color)
void fontChanged(QFont font)
void labelColorChanged(QColor color)
void markerShapeChanged(QLegend::MarkerShape shape)
void reverseMarkersChanged(bool reverseMarkers)
void showToolTipsChanged(bool showToolTips)

상세 설명

범례는 차트의 범례를 표시하는 그래픽 객체입니다. 범례 상태는 시리즈가 변경되면 QChart 에 의해 업데이트됩니다. 기본적으로 범례는 차트에 첨부되어 있지만 분리하여 차트 레이아웃과 독립적으로 만들 수 있습니다. 범례 개체는 만들거나 삭제할 수 없지만 QChart 클래스를 통해 참조할 수 있습니다.

QChart참조하세요 .

멤버 유형 문서

enum QLegend::MarkerShape

이 열거형은 범례 마커 항목을 렌더링할 때 사용되는 모양을 설명합니다.

Constant설명
QLegend::MarkerShapeDefault0QLegend 에 의해 결정된 기본 모양이 마커에 사용됩니다. 이 값은 개별 QLegendMarker 항목에 대해서만 지원됩니다.
QLegend::MarkerShapeRectangle1직사각형 마커가 사용됩니다. 마커 크기는 글꼴 크기에 따라 결정됩니다.
QLegend::MarkerShapeCircle2원형 마커가 사용됩니다. 마커 크기는 글꼴 크기에 따라 결정됩니다.
QLegend::MarkerShapeRotatedRectangle4회전된 직사각형 모양의 마커가 사용됩니다. 마커 크기는 글꼴 크기에 따라 결정됩니다.
QLegend::MarkerShapeTriangle5삼각형 마커가 사용됩니다. 마커 크기는 글꼴 크기에 따라 결정됩니다.
QLegend::MarkerShapeStar6별 모양 마커가 사용됩니다. 마커 크기는 글꼴 크기에 따라 결정됩니다.
QLegend::MarkerShapePentagon7펜타곤 모양의 마커가 사용됩니다. 마커 크기는 글꼴 크기에 따라 결정됩니다.
QLegend::MarkerShapeFromSeries3마커 모양은 계열에 따라 결정됩니다. 분산 계열의 경우 범례 마커는 분산 점처럼 보이며 점과 같은 크기입니다. 선 또는 스플라인 계열의 경우 범례 마커는 선의 작은 세그먼트처럼 보입니다. 다른 계열 유형의 경우 직사각형 마커가 표시됩니다. 계열에 lightMarker 을 지정한 경우 lightMarker 이 표시되며 계열 마커 크기에 따라 크기가 결정됩니다.

markerShape참조하세요 .

속성 문서

alignment : Qt::Alignment

범례가 차트에 정렬되는 방식.

Qt::AlignTop, Qt::AlignBottom, Qt::AlignLeft, Qt::AlignRight 일 수 있습니다. 플래그를 두 개 이상 설정하면 결과가 정의되지 않습니다.

액세스 함수:

Qt::Alignment alignment() const
void setAlignment(Qt::Alignment alignment)

backgroundVisible : bool

이 속성은 범례 배경을 표시할지 여부를 지정합니다.

액세스 함수:

bool isBackgroundVisible() const
void setBackgroundVisible(bool visible = true)

알림 신호:

void backgroundVisibleChanged(bool visible)

borderColor : QColor

이 속성은 범례의 선 색상을 저장합니다.

함수에 액세스합니다:

QColor borderColor()
void setBorderColor(QColor color)

알림 신호:

void borderColorChanged(QColor color)

color : QColor

이 속성은 범례의 배경(브러시) 색상을 보유합니다.

범례의 색상을 변경하면 범례 브러시 스타일이 Qt::SolidPattern 로 설정됩니다.

기능에 액세스합니다:

QColor color()
void setColor(QColor color)

알림 신호:

void colorChanged(QColor color)

font : QFont

이 속성에는 범례에 사용되는 마커의 글꼴이 저장됩니다.

액세스 함수:

QFont font() const
void setFont(const QFont &font)

알림 신호:

void fontChanged(QFont font)

labelColor : QColor

이 속성에는 레이블을 그리는 데 사용되는 브러시의 색상이 저장됩니다.

함수에 액세스합니다:

QColor labelColor() const
void setLabelColor(QColor color)

알림 신호:

void labelColorChanged(QColor color)

markerShape : MarkerShape

범례 마커의 기본 모양입니다. 기본값은 MarkerShapeRectangle 입니다.

기능에 액세스합니다:

QLegend::MarkerShape markerShape() const
void setMarkerShape(QLegend::MarkerShape shape)

알림 신호:

void markerShapeChanged(QLegend::MarkerShape shape)

reverseMarkers : bool

이 속성은 범례의 마커에 역순을 사용할지 여부를 저장합니다.

이 속성은 기본적으로 false 입니다.

함수에 액세스합니다:

bool reverseMarkers()
void setReverseMarkers(bool reverseMarkers = true)

알림 신호:

void reverseMarkersChanged(bool reverseMarkers)

showToolTips : bool

이 속성은 텍스트가 잘릴 때 툴팁을 표시할지 여부를 지정합니다.

이 속성은 기본적으로 false 입니다.

함수 액세스:

bool showToolTips() const
void setShowToolTips(bool show)

알림 신호:

void showToolTipsChanged(bool showToolTips)

멤버 함수 문서

[virtual noexcept] QLegend::~QLegend()

범례 객체를 삭제합니다. 범례는 항상 QChart 에 소유되므로 애플리케이션에서 이 함수를 호출해서는 안 됩니다.

void QLegend::attachToChart()

차트에 범례를 첨부합니다. 차트에서 범례의 레이아웃을 조정할 수 있습니다.

[signal, since 6.2] void QLegend::attachedToChartChanged(bool attached)

이 신호는 범례가 attached 에 있거나 차트에서 분리될 때 발생합니다.

이 기능은 Qt 6.2에 도입되었습니다.

[signal] void QLegend::backgroundVisibleChanged(bool visible)

이 신호는 범례 배경의 가시성이 visible 로 변경될 때 발생합니다.

참고: 속성 backgroundVisible 에 대한 알림 신호입니다.

[signal] void QLegend::borderColorChanged(QColor color)

이 신호는 범례 배경의 테두리 색상이 color 으로 변경될 때 발생합니다.

참고: 속성 borderColor 에 대한 알림 신호입니다.

QBrush QLegend::brush() const

범례에 사용된 브러시를 반환합니다.

setBrush()도 참조하세요 .

[signal] void QLegend::colorChanged(QColor color)

이 신호는 범례 배경 색상이 color 로 변경될 때 발생합니다.

참고: 속성 color 에 대한 알림 신호입니다.

void QLegend::detachFromChart()

차트에서 범례를 분리합니다. 차트에서 더 이상 범례의 레이아웃이 조정되지 않습니다.

[signal] void QLegend::fontChanged(QFont font)

이 신호는 범례 마커의 글꼴이 font 로 변경될 때 발생합니다.

참고: 속성에 대한 알림 신호 font.

bool QLegend::isAttachedToChart()

범례가 차트에 첨부된 경우 true 를 반환합니다.

bool QLegend::isBackgroundVisible() const

범례 배경의 가시성을 반환합니다.

참고: 속성에 대한 게터 함수 backgroundVisible.

[since 6.2] bool QLegend::isInteractive() const

범례가 분리되었을 때 마우스로 드래그하거나 크기를 조정할 수 있는지 여부를 반환합니다.

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

QLegend::setInteractive()도 참조하십시오 .

QBrush QLegend::labelBrush() const

레이블을 그리는 데 사용된 브러시를 반환합니다.

setLabelBrush()도 참조하세요 .

[signal] void QLegend::labelColorChanged(QColor color)

이 신호는 범례 레이블을 그리는 데 사용된 브러시의 색상이 color 로 변경될 때 발생합니다.

참고: 속성 labelColor 에 대한 알림 신호입니다.

QList<QLegendMarker *> QLegend::markers(QAbstractSeries *series = nullptr) const

범례에 있는 마커 목록을 반환합니다. 마커가 반환되는 series 을 지정하여 목록을 필터링할 수 있습니다.

QPen QLegend::pen() const

범례에 사용된 펜을 반환합니다.

setPen()도 참조하세요 .

[signal] void QLegend::reverseMarkersChanged(bool reverseMarkers)

이 신호는 범례에서 마커의 역순 사용이 reverseMarkers 으로 변경될 때 발생합니다.

참고: 속성 reverseMarkers 에 대한 알림 신호입니다.

void QLegend::setBackgroundVisible(bool visible = true)

범례 배경의 가시성을 visible 로 설정합니다.

참고: 속성에 대한 세터 함수 backgroundVisible.

isBackgroundVisible()도 참조하세요 .

void QLegend::setBrush(const QBrush &brush)

범례의 배경을 그리는 데 사용되는 brush 을 설정합니다.

brush()도 참조하세요 .

[since 6.2] void QLegend::setInteractive(bool interactive)

interactivetrue 이고 범례가 분리된 경우 창과 비슷한 방식으로 마우스로 범례를 이동하고 크기를 조정할 수 있습니다.

범례를 차트의 가장자리로 드래그하면 범례가 자동으로 해당 가장자리에 부착됩니다. 첨부된 범례를 두 번 클릭하면 범례가 분리됩니다. 기본값은 false 입니다.

이 기능은 Qt 6.2에 도입되었습니다.

QLegend::isInteractive()도 참조하세요 .

void QLegend::setLabelBrush(const QBrush &brush)

범례 레이블을 그리는 데 사용되는 브러시를 brush 로 설정합니다.

labelBrush()도 참조하세요 .

void QLegend::setPen(const QPen &pen)

범례 테두리를 그리는 데 사용되는 pen 을 설정합니다.

pen()도 참조하세요 .

void QLegend::setShowToolTips(bool show)

showtrue 인 경우 범례 레이블이 마우스로 가리키면 레이블 자체가 생략된 상태로 표시되어 툴팁이 표시됩니다. 기본값은 false 입니다.

참고: 속성에 대한 설정자 함수 showToolTips.

showToolTips()도 참조하세요 .

bool QLegend::showToolTips() const

범례 레이블이 생략된 경우 툴팁을 표시할지 여부를 반환합니다.

참고: 쇼툴팁 속성에 대한 게터 함수입니다.

setShowToolTips()도 참조하세요 .

[signal] void QLegend::showToolTipsChanged(bool showToolTips)

이 신호는 툴팁의 표시 여부가 showToolTips 로 변경될 때 발생합니다.

참고: 속성 showToolTips 에 대한 알림 신호입니다.

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