이 페이지에서

Qt Graphs Qt DataVisualization에서 마이그레이션

Qt DataVisualization과 Qt Graphs 간의 API 및 기능은 대부분 변경되지 않았습니다. 그러나 애플리케이션을 Qt DataVisualization에서 Qt Graphs 로 마이그레이션할 때 고려해야 할 몇 가지 차이점이 있습니다:

  • QML 임포트 문
  • CMake 모듈 포함
  • qmake 모듈 포함
  • 위젯 애플리케이션 생성
  • OpenGL 백엔드 사용 요건
  • 제거된 클래스
  • 제거된 API
  • 변경된 API

QML 임포트 문

Qt DataVisualization의 import 문:

import QtDataVisualization

다음과 같이 변경되었습니다:

import QtGraphs

Qt Graphs 의 경우 다음과 같이 변경되었습니다.

CMake 모듈 포함

Qt DataVisualization의 포함 문:

find_package(Qt6 REQUIRED COMPONENTS DataVisualization)
target_link_libraries(mytarget PRIVATE Qt6::DataVisualization)

다음과 같이 변경되었습니다:

find_package(Qt6 REQUIRED COMPONENTS Graphs)
target_link_libraries(mytarget PRIVATE Qt6::Graphs)

Qt Graphs 의 경우.

Qmake 모듈 포함

Qt DataVisualization 내 포함:

QT += datavisualization

다음과 같이 변경되었습니다:

QT += graphs

Qt Graphs 의 경우.

위젯 애플리케이션 생성

위젯 애플리케이션에서 그래프를 생성하려면 코드를 다음과 같이 변경하십시오:

Q3DBars *barGraph = new Q3DBars();
QWidget *barsWidget = new QWidget();
QWidget *container = QWidget::createWindowContainer(barGraph, barsWidget);

auto *hLayout = new QHBoxLayout(barsWidget);
hLayout->addWidget(container, 1);

다음과 같이 변경하십시오:

QQuickWidget *quickWidget = new QQuickWidget();
Q3DBarsWidgetItem *barGraph = new Q3DBarsWidgetItem();
barGraph->setWidget(quickWidget);

auto *hLayout = new QHBoxLayout(quickWidget);

OpenGL 백엔드 사용 요건

Qt Graphs 3D를 사용하기 위해 더 이상 OpenGL 백엔드 사용을 강제로 지정할 필요가 없습니다.

// Remove this line
qputenv("QSG_RHI_BACKEND", "opengl");

Qt Graphs Qt Quick 3D 를 사용하여 렌더링하므로, 실행 중인 플랫폼에 기본으로 제공되는 렌더링 백엔드를 지원합니다.

제거된 클래스

  • Q3DCamera
  • Q3DLight
  • Q3DObject
  • Q3DTheme

제거된 API

  • hasContext
  • shadowsSupported
  • reflection
  • reflectivity

변경된 API

  • 최적화 힌트
  • 렌더링 모드
  • 이미지로 렌더링
  • ColorGradient 및 ColorGradientStop
  • ThemeColor
  • 데이터 API
  • 카메라 API
  • 테마 API
  • 열거형

optimizationHint

Legacy 는 이제 QtDataVisualization에서 ` OptimizationDefault `이었던 모드와 동일합니다. ` Default `은 인스턴싱을 사용하며, 이를 지원하는 모든 대상에서 사용해야 합니다.

renderingMode

RenderDirectToBackground_NoClear 는 Qt 6의 QtDataVisualization에서 이미 사용되지 않게 되었으므로 제거되었습니다.

renderToImage

renderToImage 는 이제 ` QImage` 대신 ` QSharedPointer<QQuickItemGrabResult> `를 반환하며, 더 이상 ` msaaSamples `를 매개변수로 받지 않습니다.

ColorGradient 및 ColorGradientStop

ColorGradient 는 이제 Gradient 및 ColorGradientStop GradientStop 로 변경되었습니다.

ThemeColor

ThemeColor 는 이제 Color 입니다.

데이터 API

더 이상 new 을 사용하여 데이터 배열을 생성할 필요가 없습니다. 예를 들어, Qt DataVisualization에서 막대 그래프용 데이터를 생성할 때는 다음과 같이 처리했습니다:

// Qt DataVisualization approach.
QBarDataRow *data = new QBarDataRow;
*data << 1.0f << 3.0f << 7.5f << 5.0f << 2.2f;

이제 다음과 같이 처리됩니다:

// Qt Graphs approach.
QBarDataRow data;
data << 1.0f << 3.0f << 7.5f << 5.0f << 2.2f;
series->dataProxy()->addRow(data);

카메라 API

Q3DCamera가 제거됨에 따라, 해당 클래스의 필수 함수들이 이동되었습니다. cameraPreset, cameraTargetPosition, cameraXRotation, cameraYRotation, cameraZoomLevel, wrapCameraXRotation, and wrapCameraYRotation 는 이제 GraphsItem3D 의 일부가 되었습니다.

테마 API

Q3DTheme가 제거되고 2D 및 3D 그래프 간의 테마 적용 방식이 통합됨에 따라, 해당 라이브러리에서 사용되던 일부 필수 함수는 이동되었으며, 나머지는 대체 라이브러리인 GraphsTheme 에서 확인할 수 있습니다. lightColor, ambientLightStrength, lightStrength, and shadowStrength 는 이제 GraphsItem3D 에 구현되어 있습니다.

windowColor 가 제거되었습니다. backgroundColor 는 이제 windowColor 가 수행하던 역할을 수행하며, 새로운 함수 plotAreaBackgroundColor 는 backgroundColor 가 이전에 수행하던 기능을 대체합니다.

이제 그래프 전체의 일반 색상 구성은 color scheme 속성으로 제어되며, 시리즈 색상은 theme 속성으로 제어됩니다. 색상 구성이 명시적으로 설정되지 않은 경우, 데스크톱 테마(밝은 모드/어두운 모드)를 따릅니다.

열거형

Qt Graphs 에서는 모든 열거형이 범위 지정 열거형으로 구현됩니다. 예를 들어, Qt DataVisualization의 QAbstract3DGraph::ShadowQualityLow 에 해당하는 Qt Graphs 의 열거형은 QtGraphs3D::ShadowQuality::Low 입니다.

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