Qt Graphs 다음에서 마이그레이션 Qt Charts
Qt Charts 와 Qt Graphs 간의 API 및 기능은 약간 다릅니다. 이 문서에서는 Qt Charts 와 Qt Graphs 간의 API 차이점을 설명합니다:
QML 임포트 문
Qt Charts 의 import 문:
import QtCharts다음과 같이 변경해야 합니다:
import QtGraphsQt Graphs 의 경우 다음과 같이 변경해야 합니다.
CMake 모듈 포함
Qt Charts 의 포함 문:
find_package(Qt6 REQUIRED COMPONENTS Charts)
target_link_libraries(mytarget PRIVATE Qt6::Charts)다음과 같이 변경해야 합니다:
find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs)Qt Graphs 의 경우.
Qmake 모듈 포함
Qt Charts 파일 내의 포함 문:
QT += charts다음과 같이 변경해야 합니다:
QT += graphsQt Graphs 의 경우.
xml-ph-0000@deepl.internal에서 누락된 기능 Qt Graphs
Qt Graphs 6.8 릴리스에서는 다음과 같은 기능이 누락되어 있습니다:
- Qt Graphs 위젯
- 캔들스틱 차트
- 박스 앤 위스커 차트
- 제목 및 범례
- 로그 값 축
- 극좌표 차트 보기
테마 API
2D 및 3D 그래프 간의 테마 적용 방식이 통합되었습니다. 테마 설정에 대해서는 GraphsTheme 를 참조하십시오.
이제 전체 그래프의 일반 색상 구성은 color scheme 속성으로 제어되며, 시리즈 색상은 theme 속성으로 제어됩니다. 색상 구성이 명시적으로 설정되지 않은 경우, 데스크톱 테마(밝은/어두운)를 따릅니다.
열거형
Qt Graphs 2D에서는 모든 열거형이 범위 지정 열거형으로 구현됩니다. 예를 들어, Qt Charts 의 PieSlice.LabelOutside 에 해당하는 Qt Graphs 2D의 열거형은 PieSlice.LabelPosition.Outside 입니다.
QML에서 차트 시리즈 마이그레이션
이 섹션에서는 Qt Charts 코드를 Qt Graphs 2D로 마이그레이션하는 방법에 대한 예제를 제공합니다.
면적 시리즈 마이그레이션
다음 코드 예제는 유사한 차트를 구현합니다:
Qt Charts 를 사용한 경우:
ChartView {
anchors.fill: parent
ValueAxis {
id: valueAxisX
max: 8
}
ValueAxis {
id: valueAxisY
max: 4
}
AreaSeries {
axisX: valueAxisX
axisY: valueAxisY
upperSeries: LineSeries {
XYPoint { x: 0; y: 2 }
XYPoint { x: 1; y: 3.5 }
XYPoint { x: 2; y: 3.8 }
}
lowerSeries: LineSeries {
XYPoint { x: 0.4; y: 1.5 }
XYPoint { x: 1; y: 2.5 }
XYPoint { x: 2.4; y: 3 }
}
}
}Qt Graphs 사용 시:
GraphsView {
anchors.fill: parent
axisX: ValueAxis {
id: xAxis
max: 8
tickInterval: 2.0
}
axisY: ValueAxis {
id: yAxis
max: 4
tickInterval: 1.0
}
AreaSeries {
upperSeries: LineSeries {
XYPoint { x: 0; y: 2 }
XYPoint { x: 1; y: 3.5 }
XYPoint { x: 2; y: 3.8 }
}
lowerSeries: LineSeries {
XYPoint { x: 0.4; y: 1.5 }
XYPoint { x: 1; y: 2.5 }
XYPoint { x: 2.4; y: 3 }
}
}
}막대형 차트 시리즈 마이그레이션
Qt Charts 를 사용한 경우:
import QtQuick
import QtCharts
ChartView {
BarSeries {
id: mySeries
axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] }
BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
}
}Qt Graphs 를 사용하는 경우:
GraphsView {
axisX: BarCategoryAxis { categories: ["2007", "2008", "2009", "2010", "2011", "2012" ] }
BarSeries {
id: mySeries
BarSet { label: "Bob"; values: [2, 2, 3, 4, 5, 6] }
BarSet { label: "Susan"; values: [5, 1, 2, 4, 1, 7] }
BarSet { label: "James"; values: [3, 5, 8, 13, 5, 8] }
}
}도넛 시리즈 마이그레이션
Qt Charts 를 사용하여:
import QtQuick
import QtCharts
ChartView {
PieSeries {
id: pieOuter
size: 0.96
holeSize: 0.7
PieSlice { id: slice; label: "Alpha"; value: 19511; color: "#99CA53" }
PieSlice { label: "Epsilon"; value: 11105; color: "#209FDF" }
PieSlice { label: "Psi"; value: 9352; color: "#F6A625" }
}
PieSeries {
id: pieInner
size: 0.7
holeSize: 0.25
PieSlice { label: "Materials"; value: 10334; color: "#B9DB8A" }
PieSlice { label: "Employee"; value: 3066; color: "#DCEDC4" }
PieSlice { label: "Logistics"; value: 6111; color: "#F3F9EB" }
PieSlice { label: "Materials"; value: 7371; color: "#63BCE9" }
PieSlice { label: "Employee"; value: 2443; color: "#A6D9F2" }
PieSlice { label: "Logistics"; value: 1291; color: "#E9F5FC" }
PieSlice { label: "Materials"; value: 4022; color: "#F9C36C" }
PieSlice { label: "Employee"; value: 3998; color: "#FCE1B6" }
PieSlice { label: "Logistics"; value: 1332; color: "#FEF5E7" }
}
Component.onCompleted: {
// Set the common slice properties dynamically for convenience
for (var i = 0; i < pieOuter.count; i++) {
pieOuter.at(i).labelPosition = PieSlice.LabelOutside;
pieOuter.at(i).labelVisible = true;
pieOuter.at(i).borderWidth = 3;
}
for (var i = 0; i < pieInner.count; i++) {
pieInner.at(i).labelPosition = PieSlice.LabelInsideNormal;
pieInner.at(i).labelVisible = true;
pieInner.at(i).borderWidth = 2;
}
}
}Qt Graphs 를 사용하여:
GraphsView {
PieSeries {
id: pieOuter
pieSize: 0.96
holeSize: 0.7
PieSlice { id: slice; label: "Alpha"; value: 19511; color: "#99CA53" }
PieSlice { label: "Epsilon"; value: 11105; color: "#209FDF" }
PieSlice { label: "Psi"; value: 9352; color: "#F6A625" }
}
PieSeries {
id: pieInner
pieSize: 0.7
holeSize: 0.25
PieSlice { label: "Materials"; value: 10334; color: "#B9DB8A" }
PieSlice { label: "Employee"; value: 3066; color: "#DCEDC4" }
PieSlice { label: "Logistics"; value: 6111; color: "#F3F9EB" }
PieSlice { label: "Materials"; value: 7371; color: "#63BCE9" }
PieSlice { label: "Employee"; value: 2443; color: "#A6D9F2" }
PieSlice { label: "Logistics"; value: 1291; color: "#E9F5FC" }
PieSlice { label: "Materials"; value: 4022; color: "#F9C36C" }
PieSlice { label: "Employee"; value: 3998; color: "#FCE1B6" }
PieSlice { label: "Logistics"; value: 1332; color: "#FEF5E7" }
}
Component.onCompleted: {
// Set the common slice properties dynamically for convenience
for (var i = 0; i < pieOuter.count; i++) {
pieOuter.at(i).labelPosition = PieSlice.LabelPosition.Outside;
pieOuter.at(i).labelVisible = true;
pieOuter.at(i).borderWidth = 3;
}
for (var i = 0; i < pieInner.count; i++) {
pieInner.at(i).labelPosition = PieSlice.LabelPosition.InsideNormal;
pieInner.at(i).labelVisible = true;
pieInner.at(i).borderWidth = 2;
}
}
}Line 시리즈 마이그레이션
Qt Charts 를 사용하여:
ChartView {
LineSeries {
XYPoint { x: 0; y: 0 }
XYPoint { x: 1.1; y: 2.1 }
XYPoint { x: 1.9; y: 3.3 }
XYPoint { x: 2.1; y: 2.1 }
XYPoint { x: 2.9; y: 4.9 }
XYPoint { x: 3.4; y: 3.0 }
XYPoint { x: 4.1; y: 3.3 }
}
}Qt Graphs 를 사용하여:
GraphsView {
// Graphs don't calculate a visible range for axes.
// You should define the visible range explicitly.
axisX: ValueAxis {
id: xAxis
max: 4.1
}
axisY: ValueAxis {
id: yAxis
max: 4.9
}
LineSeries {
XYPoint { x: 0; y: 0 }
XYPoint { x: 1.1; y: 2.1 }
XYPoint { x: 1.9; y: 3.3 }
XYPoint { x: 2.1; y: 2.1 }
XYPoint { x: 2.9; y: 4.9 }
XYPoint { x: 3.4; y: 3.0 }
XYPoint { x: 4.1; y: 3.3 }
}
}파이 시리즈 마이그레이션
Qt Charts 를 사용하여:
ChartView {
property variant othersSlice: 0
PieSeries {
id: pieSeries
PieSlice { label: "Volkswagen"; value: 13.5 }
PieSlice { label: "Toyota"; value: 10.9 }
PieSlice { label: "Ford"; value: 8.6 }
PieSlice { label: "Skoda"; value: 8.2 }
PieSlice { label: "Volvo"; value: 6.8 }
}
Component.onCompleted: {
othersSlice = pieSeries.append("Others", 52.0);
pieSeries.find("Volkswagen").exploded = true;
}
}Qt Graphs 를 사용하여:
GraphsView {
property variant othersSlice: 0
PieSeries {
id: pieSeries
PieSlice { label: "Volkswagen"; value: 13.5 }
PieSlice { label: "Toyota"; value: 10.9 }
PieSlice { label: "Ford"; value: 8.6 }
PieSlice { label: "Skoda"; value: 8.2 }
PieSlice { label: "Volvo"; value: 6.8 }
}
Component.onCompleted: {
othersSlice = pieSeries.append("Others", 52.0);
pieSeries.find("Volkswagen").exploded = true;
}
}Scatter 시리즈 마이그레이션
Qt Charts 를 사용하여:
ChartView {
ScatterSeries {
XYPoint { x: 1.5; y: 1.5 }
XYPoint { x: 1.5; y: 1.6 }
XYPoint { x: 1.57; y: 1.55 }
XYPoint { x: 1.8; y: 1.8 }
XYPoint { x: 1.9; y: 1.6 }
XYPoint { x: 2.1; y: 1.3 }
XYPoint { x: 2.5; y: 2.1 }
}
}Qt Graphs 를 사용하여:
GraphsView {
// Graphs don't calculate a visible range for axes.
// You should define the visible range explicitly.
ValueAxis {
id: xyAxis
min: 1.3
max: 2.5
}
axisX: xyAxis
axisY: xyAxis
ScatterSeries {
XYPoint { x: 1.5; y: 1.5 }
XYPoint { x: 1.5; y: 1.6 }
XYPoint { x: 1.57; y: 1.55 }
XYPoint { x: 1.8; y: 1.8 }
XYPoint { x: 1.9; y: 1.6 }
XYPoint { x: 2.1; y: 1.3 }
XYPoint { x: 2.5; y: 2.1 }
}
}스플라인 계열의 마이그레이션
Qt Charts 를 사용하여:
ChartView {
SplineSeries {
name: "Spline"
XYPoint { x: 0; y: 0.0 }
XYPoint { x: 1.1; y: 3.2 }
XYPoint { x: 1.9; y: 2.4 }
XYPoint { x: 2.1; y: 2.1 }
XYPoint { x: 2.9; y: 2.6 }
XYPoint { x: 3.4; y: 2.3 }
XYPoint { x: 4.1; y: 3.1 }
}
}Qt Graphs 를 사용하여:
GraphsView {
ValueAxis {
id: xyAxis
max: 5
}
axisX: xyAxis
axisY: xyAxis
SplineSeries {
XYPoint { x: 0; y: 0.0 }
XYPoint { x: 1.1; y: 3.2 }
XYPoint { x: 1.9; y: 2.4 }
XYPoint { x: 2.1; y: 2.1 }
XYPoint { x: 2.9; y: 2.6 }
XYPoint { x: 3.4; y: 2.3 }
XYPoint { x: 4.1; y: 3.1 }
}
}© 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.