QLegend Class
QLegend 클래스는 차트의 범례를 표시합니다. 더 보기...
| Header: | #include <QLegend> |
| In QML: | Legend |
| Inherits: | QGraphicsWidget |
| Status: | Deprecated |
이 클래스는 더 이상 사용되지 않습니다. 새로운 코드에서는 이 클래스를 사용하지 않는 것을 강력히 권장합니다.
공개 유형
| 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
이 열거형은 범례 마커 항목을 렌더링할 때 사용되는 모양을 설명합니다.
| 상수 | 값 | 설명 |
|---|---|---|
QLegend::MarkerShapeDefault | 0 | QLegend 에 의해 결정된 기본 도형이 마커에 사용됩니다. 이 값은 개별 QLegendMarker 항목에서만 지원됩니다. |
QLegend::MarkerShapeRectangle | 1 | 직사각형 마커가 사용됩니다. 마커 크기는 글꼴 크기에 따라 결정됩니다. |
QLegend::MarkerShapeCircle | 2 | 원형 마커가 사용됩니다. 마커 크기는 글꼴 크기에 따라 결정됩니다. |
QLegend::MarkerShapeRotatedRectangle | 4 | 회전된 직사각형 모양의 마커가 사용됩니다. 마커 크기는 글꼴 크기에 따라 결정됩니다. |
QLegend::MarkerShapeTriangle | 5 | 삼각형 마커가 사용됩니다. 마커 크기는 글꼴 크기에 따라 결정됩니다. |
QLegend::MarkerShapeStar | 6 | 별 모양 마커가 사용됩니다. 마커 크기는 글꼴 크기에 따라 결정됩니다. |
QLegend::MarkerShapePentagon | 7 | 오각형 마커가 사용됩니다. 마커 크기는 글꼴 크기에 따라 결정됩니다. |
QLegend::MarkerShapeFromSeries | 3 | 마커 모양은 시리즈에 따라 결정됩니다. 산점도 시리즈의 경우, 범례 마커는 산점도 점과 같은 모양이며 점과 동일한 크기를 가집니다. 선 또는 스플라인 시리즈의 경우, 범례 마커는 선의 작은 구간과 같은 모양을 가집니다. 그 외의 시리즈 유형의 경우, 직사각형 마커가 표시됩니다. 시리즈에 수직 축 마커( 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`에 대한알림 신호입니다.
[signal] void QLegend::markerShapeChanged(QLegend::MarkerShape shape)
이 신호는 범례 마커의 모양이 ‘ shape ’로 변경될 때 발생합니다.
참고: 속성 markerShape 에 대한알림 신호입니다.
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)
interactive 가 true 상태이고 범례가 분리되어 있을 때, 범례는 창과 비슷한 방식으로 마우스를 사용하여 이동하거나 크기를 조정할 수 있습니다.
범례를 차트의 가장자리 밖으로 드래그하면 범례가 자동으로 차트의 가장자리에 부착됩니다. 부착된 범례를 더블 클릭하면 분리됩니다. 이는 기본적으로 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)
show 가 true 인 경우, 레이블 자체가 축약된 형태로 표시될 때 마우스를 레이블 위로 가져가면 툴팁이 나타납니다. 기본값은 false 입니다.
참고: showToolTips 속성의세터 함수입니다.
showToolTips()도 참조하십시오 .
bool QLegend::showToolTips() const
축척표 레이블이 생략된 경우 툴팁이 표시되는지 여부를 반환합니다.
참고: showToolTips 속성에 대한게터 함수입니다.
setShowToolTips()도 참조하십시오 .
[signal] void QLegend::showToolTipsChanged(bool showToolTips)
이 신호는 툴팁 표시 설정이 ` showToolTips`로 변경될 때 발생합니다.
참고: 속성 showToolTips 에 대한알림 신호입니다.
© 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.