QChart Class

QChart 클래스는 차트의 계열, 범례 및 축의 그래픽 표현을 관리합니다. 더 보기...

Header: #include <QChart>
Inherits: QGraphicsWidget
Inherited By:

QPolarChart

공용 유형

enum AnimationOption { NoAnimation, GridAxisAnimations, SeriesAnimations, AllAnimations }
flags AnimationOptions
enum ChartTheme { ChartThemeLight, ChartThemeBlueCerulean, ChartThemeDark, ChartThemeBrownSand, ChartThemeBlueNcs, …, ChartThemeQt }
enum ChartType { ChartTypeUndefined, ChartTypeCartesian, ChartTypePolar }

속성

공공 기능

QChart(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = Qt::WindowFlags())
virtual ~QChart()
void addAxis(QAbstractAxis *axis, Qt::Alignment alignment)
void addSeries(QAbstractSeries *series)
int animationDuration() const
QEasingCurve animationEasingCurve() const
QChart::AnimationOptions animationOptions() const
QList<QAbstractAxis *> axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries *series = nullptr) const
QBrush backgroundBrush() const
QPen backgroundPen() const
qreal backgroundRoundness() const
QChart::ChartType chartType() const
void createDefaultAxes()
bool isBackgroundVisible() const
bool isDropShadowEnabled() const
bool isPlotAreaBackgroundVisible() const
bool isZoomed()
QLegend *legend() const
QLocale locale() const
bool localizeNumbers() const
QPointF mapToPosition(const QPointF &value, QAbstractSeries *series = nullptr)
QPointF mapToValue(const QPointF &position, QAbstractSeries *series = nullptr)
QMargins margins() const
QRectF plotArea() const
QBrush plotAreaBackgroundBrush() const
QPen plotAreaBackgroundPen() const
void removeAllSeries()
void removeAxis(QAbstractAxis *axis)
void removeSeries(QAbstractSeries *series)
void scroll(qreal dx, qreal dy)
QList<QAbstractSeries *> series() const
void setAnimationDuration(int msecs)
void setAnimationEasingCurve(const QEasingCurve &curve)
void setAnimationOptions(QChart::AnimationOptions options)
void setBackgroundBrush(const QBrush &brush)
void setBackgroundPen(const QPen &pen)
void setBackgroundRoundness(qreal diameter)
void setBackgroundVisible(bool visible = true)
void setDropShadowEnabled(bool enabled = true)
void setLocale(const QLocale &locale)
void setLocalizeNumbers(bool localize)
void setMargins(const QMargins &margins)
void setPlotArea(const QRectF &rect)
void setPlotAreaBackgroundBrush(const QBrush &brush)
void setPlotAreaBackgroundPen(const QPen &pen)
void setPlotAreaBackgroundVisible(bool visible = true)
void setTheme(QChart::ChartTheme theme)
void setTitle(const QString &title)
void setTitleBrush(const QBrush &brush)
void setTitleFont(const QFont &font)
QChart::ChartTheme theme() const
QString title() const
QBrush titleBrush() const
QFont titleFont() const
void zoom(qreal factor)
void zoomIn()
void zoomIn(const QRectF &rect)
void zoomOut()
void zoomReset()

신호

void plotAreaChanged(const QRectF &plotArea)

상세 설명

QChart는 QGraphicsScene 에 표시할 수 있는 QGraphicsWidget 로, 다양한 유형의 계열과 범례 및 축과 같은 기타 차트 관련 객체의 그래픽 표현을 관리합니다. 레이아웃에 차트를 간단히 표시하려면 QChart 대신 편의 클래스 QChartView 를 사용할 수 있습니다. 또한 QPolarChart 클래스를 사용하여 선, 스플라인, 면적 및 분산형 계열을 극좌표 차트로 표시할 수 있습니다.

QChartViewQPolarChart참조하세요 .

멤버 유형 문서

열거형 QChart::애니메이션 옵션
플래그 QChart::애니메이션 옵션

이 열거형은 차트에서 활성화된 애니메이션을 설명합니다.

상수설명
QChart::NoAnimation0x0차트에서 애니메이션이 비활성화됩니다. 기본값입니다.
QChart::GridAxisAnimations0x1차트에서 그리드 축 애니메이션이 활성화됩니다.
QChart::SeriesAnimations0x2차트에서 시리즈 애니메이션이 활성화됩니다.
QChart::AllAnimations0x3차트에서 모든 애니메이션 유형이 활성화됩니다.

애니메이션 옵션 유형은 QFlags<AnimationOption>에 대한 유형 정의입니다. 이 유형은 애니메이션 옵션 값의 OR 조합을 저장합니다.

enum QChart::ChartTheme

이 열거형은 차트에서 사용하는 테마를 설명합니다.

테마는 색상, 펜, 브러시, 계열의 글꼴, 축, 제목, 범례 등 차트의 모든 시각적 요소에 적용되는 UI 스타일 관련 설정의 기본 제공 모음입니다. 위젯이 있는 차트 갤러리에서는 테마를 사용하는 방법을 설명합니다.

참고: 테마를 변경하면 이전에 시리즈에 적용된 모든 사용자 지정을 덮어씁니다.

상수설명
QChart::ChartThemeLight0기본 테마인 밝은 테마.
QChart::ChartThemeBlueCerulean1청록색 테마.
QChart::ChartThemeDark2어두운 테마.
QChart::ChartThemeBrownSand3샌드 브라운 테마.
QChart::ChartThemeBlueNcs4자연색 시스템(NCS) 파란색 테마.
QChart::ChartThemeHighContrast5고대비 테마.
QChart::ChartThemeBlueIcy6아이스 블루 테마.
QChart::ChartThemeQt7Qt 테마.

enum QChart::ChartType

이 열거형은 차트 유형을 설명합니다.

Constant설명
QChart::ChartTypeUndefined0차트 유형이 정의되지 않았습니다.
QChart::ChartTypeCartesian1직교 차트.
QChart::ChartTypePolar2극좌표형 차트입니다.

속성 문서

animationDuration : int

이 속성은 차트의 애니메이션 지속 시간을 보유합니다.

액세스 함수:

int animationDuration() const
void setAnimationDuration(int msecs)

animationEasingCurve : QEasingCurve

이 속성은 차트에 대한 애니메이션의 완화 곡선을 보유합니다.

함수에 액세스합니다:

QEasingCurve animationEasingCurve() const
void setAnimationEasingCurve(const QEasingCurve &curve)

animationOptions : QChart::AnimationOptions

이 속성에는 차트의 애니메이션 옵션이 있습니다.

이 설정에 따라 애니메이션이 활성화 또는 비활성화됩니다.

함수 액세스:

QChart::AnimationOptions animationOptions() const
void setAnimationOptions(QChart::AnimationOptions options)

backgroundRoundness : qreal

이 속성은 차트 배경 모서리에 있는 반올림 원의 지름을 유지합니다.

함수에 액세스합니다:

qreal backgroundRoundness() const
void setBackgroundRoundness(qreal diameter)

backgroundVisible : bool

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

함수에 액세스합니다:

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

setBackgroundBrush(), setBackgroundPen() 및 plotAreaBackgroundVisible참조하세요 .

[read-only] chartType : const QChart::ChartType

이 속성은 차트가 직교 차트인지 극형 차트인지를 나타냅니다.

이 속성은 내부적으로 설정되며 읽기 전용입니다.

함수에 액세스합니다:

QChart::ChartType chartType() const

QPolarChart참조하세요 .

dropShadowEnabled : bool

이 속성은 배경 그림자 효과의 활성화 여부를 저장합니다.

true 로 설정하면 배경 그림자 효과가 활성화됩니다. false 로 설정하면 비활성화됩니다.

참고: 그림자 효과는 테마에 따라 달라지므로 테마가 변경되면 설정이 변경될 수 있습니다.

기능에 액세스합니다:

bool isDropShadowEnabled() const
void setDropShadowEnabled(bool enabled = true)

locale : QLocale

이 속성은 다양한 차트 레이블의 서식을 지정하는 데 사용되는 로캘을 보유합니다.

레이블은 localizeNumberstrue 일 때만 현지화되며, QDateTimeAxis 레이블은 항상 이 속성으로 설정된 QLocale 을 사용합니다.

기본값은 차트가 생성될 당시의 애플리케이션 기본 로캘입니다.

액세스 함수:

QLocale locale() const
void setLocale(const QLocale &locale)

localizeNumbers참조하세요 .

localizeNumbers : bool

이 속성은 숫자의 현지화 여부를 보유합니다.

true 인 경우 다양한 계열 및 축 레이블에 표시되는 모든 생성된 숫자는 locale 속성으로 설정된 QLocale 을 사용하여 현지화됩니다. false 인 경우 항상 C 로캘이 사용됩니다. 기본값은 false 입니다.

참고: 이 속성은 항상 로캘 속성과 함께 설정된 QLocale 을 사용하는 QDateTimeAxis 레이블에는 영향을 미치지 않습니다.

액세스 기능:

bool localizeNumbers() const
void setLocalizeNumbers(bool localize)

locale참조하세요 .

margins : QMargins

이 속성은 차트 사각형의 가장자리와 그림 영역 사이에 허용되는 최소 여백을 유지합니다.

여백은 제목, 축 및 범례를 그리는 데 사용됩니다.

함수에 액세스합니다:

QMargins margins() const
void setMargins(const QMargins &margins)

plotArea : QRectF

이 속성은 차트가 그려지는 직사각형을 보유합니다.

플롯 영역에는 여백으로 정의된 영역이 포함되지 않습니다. 기본적으로 QChartView 안에 있는 경우 크기가 조정됩니다. 플롯 영역에 대한 명시적 크기가 설정된 경우 이를 존중하여 기본 동작으로 되돌리려면 setPlotArea(QRectF()); 을 호출하면 됩니다.

함수 액세스:

QRectF plotArea() const
void setPlotArea(const QRectF &rect)

알림 신호:

void plotAreaChanged(const QRectF &plotArea)

plotAreaBackgroundVisible : bool

이 속성은 차트 플롯 영역 배경을 표시할지 여부를 결정합니다.

참고: 기본적으로 플롯 영역 배경은 보이지 않으며 플롯 영역은 일반 차트 배경을 사용합니다.

함수 액세스:

bool isPlotAreaBackgroundVisible() const
void setPlotAreaBackgroundVisible(bool visible = true)

setPlotAreaBackgroundBrush(), setPlotAreaBackgroundPen() 및 backgroundVisible참조하세요 .

theme : QChart::ChartTheme

이 속성에는 차트에 사용되는 테마가 저장됩니다.

액세스 함수:

QChart::ChartTheme theme() const
void setTheme(QChart::ChartTheme theme)

title : QString

이 속성은 차트의 제목을 저장합니다.

제목은 차트 상단에 헤드라인으로 표시됩니다. 차트 제목은 HTML 서식을 지원합니다.

함수에 액세스합니다:

QString title() const
void setTitle(const QString &title)

멤버 함수 문서

[explicit] QChart::QChart(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = Qt::WindowFlags())

parent 의 자식인 차트 객체를 생성합니다. wFlags 에 지정된 속성은 QGraphicsWidget 생성자에게 전달됩니다.

[virtual noexcept] QChart::~QChart()

차트 개체와 차트 개체에 추가된 계열 및 축 개체와 같은 하위 개체를 삭제합니다.

void QChart::addAxis(QAbstractAxis *axis, Qt::Alignment alignment)

alignment 에 지정된 대로 정렬된 차트에 axis 축을 추가합니다. 차트는 축의 소유권을 갖습니다.

removeAxis(), createDefaultAxes() 및 QAbstractSeries::attachAxis()도 참조하세요 .

void QChart::addSeries(QAbstractSeries *series)

차트에 series 시리즈를 추가하고 소유권을 가져옵니다.

참고: 새로 추가된 계열은 기본적으로 어떤 축에도 첨부되지 않으며, 계열이 차트에 추가되기 전에 createDefaultAxes()를 사용하여 차트에 대해 생성되었을 수도 있는 축에도 첨부되지 않습니다. 차트가 표시되기 전에 새로 추가된 계열에 축이 첨부되지 않으면 계열이 차트의 플롯 영역에 정확히 맞는 범위의 축이 있는 것처럼 계열이 그려집니다. 동일한 차트에 축이 제대로 연결된 다른 계열도 표시되는 경우 혼란스러울 수 있으므로 계열을 추가한 후 항상 createDefaultAxes()를 호출하거나 계열에 축을 명시적으로 첨부해야 합니다.

removeSeries(), removeAllSeries(), createDefaultAxes() 및 QAbstractSeries::attachAxis()도 참조하세요 .

QList<QAbstractAxis *> QChart::axes(Qt::Orientations orientation = Qt::Horizontal|Qt::Vertical, QAbstractSeries *series = nullptr) const

orientation 에서 지정한 방향의 계열 series 에 연결된 축을 반환합니다. 계열을 지정하지 않으면 지정된 방향으로 차트에 추가된 모든 축이 반환됩니다.

addAxis() 및 createDefaultAxes()도 참조하십시오 .

QBrush QChart::backgroundBrush() const

차트 영역의 배경을 그리는 데 사용되는 브러시를 가져옵니다.

setBackgroundBrush()도 참조하세요 .

QPen QChart::backgroundPen() const

차트 영역의 배경을 칠하는 데 사용되는 펜을 가져옵니다.

setBackgroundPen()도 참조하세요 .

void QChart::createDefaultAxes()

차트에 이미 추가된 계열을 기준으로 차트의 축을 만듭니다. 이전에 차트에 추가된 모든 축은 삭제됩니다.

참고: 이 함수는 차트에 모든 시리즈가 추가된 후에 호출해야 합니다. 이 함수가 호출된 후 차트에 추가된 계열에는 이 함수로 만든 축이 자동으로 첨부되지 않습니다. 축이 연결되지 않은 계열은 기본적으로 차트의 전체 플롯 영역을 활용하도록 배율이 조정되므로 축이 제대로 연결된 다른 계열도 있는 경우 혼동될 수 있습니다.

시리즈 유형가로 축(X)세로축(Y)
QXYSeriesQValueAxisQValueAxis
QBarSeriesQBarCategoryAxisQValueAxis
QPieSeries없음없음

차트에 여러 개의 QXYSeries 파생 시리즈가 추가되어 있고 다른 유형의 시리즈가 추가되지 않은 경우 한 쌍의 축만 생성됩니다. 차트에 서로 다른 유형의 시리즈가 여러 개 추가된 경우 각 시리즈에 고유한 축 쌍이 생깁니다.

나중에 axes() 함수 호출의 매개 변수로 시리즈를 제공하여 차트에서 시리즈에 특정한 축을 가져올 수 있습니다. QPieSeries 은 축을 만들지 않습니다.

axes() 및 QAbstractSeries::attachAxis()도 참조하세요 .

bool QChart::isZoomed()

시리즈에 확대된 도메인이 있는 경우 true 을 반환합니다.

QLegend *QChart::legend() const

차트의 범례 개체를 반환합니다. 소유권은 차트에 그대로 유지됩니다.

QPointF QChart::mapToPosition(const QPointF &value, QAbstractSeries *series = nullptr)

series 에서 지정한 계열에서 value 값에 해당하는 차트상의 위치를 반환합니다.

QPointF QChart::mapToValue(const QPointF &position, QAbstractSeries *series = nullptr)

차트에서 position 으로 지정한 위치에 series 으로 지정한 계열의 값을 반환합니다.

QBrush QChart::plotAreaBackgroundBrush() const

차트의 플롯 영역의 배경을 채우는 데 사용되는 브러시를 반환합니다.

plotArea(), plotAreaBackgroundVisible, plotAreaBackgroundPen() 및 setPlotAreaBackgroundBrush()도 참조하세요 .

QPen QChart::plotAreaBackgroundPen() const

차트의 플롯 영역의 배경을 그리는 데 사용된 펜을 반환합니다.

plotArea(), plotAreaBackgroundVisible, plotAreaBackgroundBrush() 및 setPlotAreaBackgroundPen()도 참조하세요 .

void QChart::removeAllSeries()

차트에 추가된 모든 시리즈 개체를 제거 및 삭제합니다.

addSeries() 및 removeSeries()도 참조하세요 .

void QChart::removeAxis(QAbstractAxis *axis)

차트에서 axis 축을 제거합니다. 차트에서 지정된 axis 개체의 소유권을 해제합니다.

addAxis(), createDefaultAxes() 및 QAbstractSeries::detachAxis()도 참조하세요 .

void QChart::removeSeries(QAbstractSeries *series)

차트에서 series 시리즈를 제거합니다. 차트에서 지정된 series 개체의 소유권을 해제합니다.

addSeries() 및 removeAllSeries()도 참조하세요 .

void QChart::scroll(qreal dx, qreal dy)

dxdy 에서 지정한 거리만큼 차트의 표시 영역을 스크롤합니다.

극좌표 차트의 경우 dx 은 거리 대신 각도 축을 따라 각도를 나타냅니다.

QList<QAbstractSeries *> QChart::series() const

차트에 추가된 모든 계열을 반환합니다.

addSeries(), removeSeries() 및 removeAllSeries()도 참조하세요 .

void QChart::setBackgroundBrush(const QBrush &brush)

차트 영역의 배경을 칠하는 데 사용되는 브러시를 brush 로 설정합니다.

backgroundBrush()도 참조하세요 .

void QChart::setBackgroundPen(const QPen &pen)

차트 영역의 배경을 칠하는 데 사용되는 펜을 pen 으로 설정합니다.

backgroundPen()도 참조하세요 .

void QChart::setPlotAreaBackgroundBrush(const QBrush &brush)

차트의 그림 영역의 배경을 채우는 데 사용되는 브러시를 brush 로 설정합니다.

plotArea(), plotAreaBackgroundVisible, setPlotAreaBackgroundPen() 및 plotAreaBackgroundBrush()도 참조하세요 .

void QChart::setPlotAreaBackgroundPen(const QPen &pen)

차트의 플롯 영역 배경을 그리는 데 사용되는 펜을 pen 으로 설정합니다.

plotArea(), plotAreaBackgroundVisible, setPlotAreaBackgroundBrush() 및 plotAreaBackgroundPen()도 참조하세요 .

void QChart::setTitleBrush(const QBrush &brush)

제목 텍스트를 그리는 데 사용되는 브러시를 brush 로 설정합니다.

titleBrush()도 참조하세요 .

void QChart::setTitleFont(const QFont &font)

차트 제목을 그리는 데 사용되는 글꼴을 font 으로 설정합니다.

titleFont()도 참조하세요 .

QBrush QChart::titleBrush() const

제목 텍스트를 그리는 데 사용된 브러시를 반환합니다.

setTitleBrush()도 참조하세요 .

QFont QChart::titleFont() const

차트 제목을 그리는 데 사용되는 글꼴을 가져옵니다.

setTitleFont()도 참조하세요 .

void QChart::zoom(qreal factor)

사용자 지정 배율로 뷰를 확대합니다 factor.

1.0을 초과하는 배율은 뷰를 확대하고 0.0에서 1.0 사이의 배율은 뷰를 축소합니다.

void QChart::zoomIn()

뷰를 두 배로 확대합니다.

void QChart::zoomIn(const QRectF &rect)

사각형 rect 이 여전히 완전히 표시되는 최대 수준까지 뷰를 확대합니다.

참고: 확대/축소를 적용하면 연결된 축의 속성(예: QAbstractAxis::min 및 QAbstractAxis::max)이 수정될 수 있습니다.

참고: 극좌표형 차트에는 이 기능이 지원되지 않습니다.

void QChart::zoomOut()

뷰를 2배 축소합니다.

참고: 결과에 잘못된 로그 축 범위가 포함된 경우 아무 효과가 없습니다.

void QChart::zoomReset()

시리즈 도메인을 확대/축소 메서드를 호출하기 전의 상태로 초기화합니다.

참고: 첫 번째 확대/축소 작업과 이 메서드 호출 사이에 지정된 스크롤 및 명시적 축 범위 설정도 초기화됩니다. 확대/축소 작업이 수행되지 않은 경우 이 메서드는 아무 작업도 수행하지 않습니다.

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