스플라인 차트 만들기

스플라인 차트 예시를 보여주는 스크린샷

스플라인 차트를 만들려면 데이터를 QSplineSeries에 넣어야 합니다. QSplineSeries는 스플라인을 올바르게 그리는 데 필요한 스플라인 세그먼트 제어점을 자동으로 계산합니다.

auto series = new QSplineSeries;
series->setName("Spline");

이제 시계에 몇 가지 데이터 포인트를 추가해 보겠습니다.

series->append(0, 6);
series->append(2, 4);
series->append(3, 8);
series->append(7, 4);
series->append(10, 5);
*series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2);

데이터 시리가 채워졌습니다. 차트에 이를 표시하려면 QChart 객체를 생성하고 해당 객체에 데이터 시리를 추가합니다. 또한 차트의 가독성을 높이기 위해 제목과 y축의 값 범위를 설정합니다.

auto chart = new QChart;
chart->legend()->hide();
chart->addSeries(series);
chart->setTitle("Simple Spline Chart");
chart->createDefaultAxes();
chart->axes(Qt::Vertical).first()->setRange(0, 10);

그런 다음 QChart를 매개변수로 사용하여 QChartView 객체를 생성합니다. 이렇게 하면 QGraphicsView 장면을 직접 생성할 필요가 없습니다.

createDefaultChartView(chart);

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