스플라인 차트 만들기

스플라인 차트를 만들려면 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);

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