Qt Charts C++ 類

用於 Qt Charts API 的 C++ 類。 更多...

This module is deprecated since 6.10. We strongly advise against using it in new code.

QAbstractAxis

用於專用軸類的基類

QAbstractBarSeries

用於所有條形係列類的抽象父級類

QAbstractSeries

用於所有 Qt Chart 係列的基類

QAreaLegendMarker

Legend marker for an area series

QAreaSeries

在區域圖錶中呈現數據

QBarCategoryAxis

將類彆添加到圖錶軸

QBarLegendMarker

Legend marker for a bar series

QBarSeries

將一係列數據按類彆分組呈現為垂直條形

QBarSet

錶示條形圖錶中的一組條形

QBoxPlotLegendMarker

Legend marker for a box plot series

QBoxPlotSeries

Presents data in box-and-whiskers charts

QBoxSet

Represents one item in a box-and-whiskers chart

QCandlestickLegendMarker

Legend marker for a candlestick series

QCandlestickModelMapper

Abstract model mapper class for candlestick series

QCandlestickSeries

Presents data as candlesticks

QCandlestickSet

Represents a single candlestick item in a candlestick chart

QCategoryAxis

Places named ranges on the axis

QChart

管理圖錶的係列、圖例和軸的圖形錶示

QChartView

可以顯示圖錶的獨立 Widget

QColorAxis

Displays a color scale as one of the chart's axes

QDateTimeAxis

Adds dates and times to a chart's axis

QHBarModelMapper

Horizontal model mapper for bar series

QHBoxPlotModelMapper

Horizontal model mapper for box plot series

QHCandlestickModelMapper

Horizontal model mapper for a candlestick series

QHPieModelMapper

Horizontal model mapper for pie series

QHXYModelMapper

Horizontal model mapper for line, spline, and scatter series

QHorizontalBarSeries

Presents a series of data as horizontal bars grouped by category

QHorizontalPercentBarSeries

Presents a series of categorized data as a percentage of each category

QHorizontalStackedBarSeries

Presents a series of data as horizontally stacked bars, with one bar per category

QLegend

顯示圖錶的圖例

QLegendMarker

Abstract object that can be used to access markers within a legend

QLineSeries

以綫圖錶形式呈現數據

QLogValueAxis

Adds a logarithmic scale to a chart's axis

QPercentBarSeries

Presents a series of categorized data as a percentage of each category

QPieLegendMarker

Legend marker for a pie series

QPieSeries

Presents data in pie charts

QPieSlice

Represents a single slice in a pie series

QPolarChart

Presents data in polar charts

QScatterSeries

Presents data in scatter charts

QSplineSeries

以樣條綫圖錶形式呈現數據

QStackedBarSeries

Presents a series of data as vertically stacked bars, with one bar per category

QVBarModelMapper

Vertical model mapper for bar series

QVBoxPlotModelMapper

Vertical model mapper for box plot series

QVCandlestickModelMapper

Vertical model mapper for a candlestick series

QVPieModelMapper

Vertical model mapper for pie series

QVXYModelMapper

Vertical model mapper for line, spline, and scatter series

QValueAxis

將值添加到圖錶軸

QXYLegendMarker

Legend marker for a line, spline, or scatter series

QXYSeries

Base class for line, spline, and scatter series

詳細描述

使用 QtGraphs 代替。

Charts API 構建於 Qt 圖形視圖框架之上。Charts 可以顯示為 QGraphicsWidget 使用 QChart 類。不管怎樣,還有方便類 QChartView ,其是 QWidget 基於。這些使我們能夠快速將 Qt Charts 用作正常 Qt 小部件。

注意: The Qt Charts module has been deprecated since Qt 6.10. For new projects, use the Qt Graphs module instead. Qt Graphs uses each platform's native rendering backend (Metal on macOS, DirectX on Windows, OpenGL or Vulkan on Linux) to achieve hardware-accelerated rendering for both 2D and 3D graphs. Qt Graphs uses Qt Quick 形狀 for 2D graph rendering, instead of the outdated Qt Graphics View Framework used by the Qt Charts module. To migrate from Qt Charts to Qt Graphs module, refer to Qt Graphs Migration from Qt Charts .

Using a Qt module's C++ API requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including CMake and qmake.

注意: 采用 Qt Creator 的 Qt Quick 應用程序嚮導創建的工程是基於 Qt Quick 2 的模闆使用 QGuiApplication 默認情況下。所有這種 QGuiApplication 實例在工程中均必須被替換采用 QApplication 因為模塊依賴於 Qt 的 圖形視圖框架 為渲染。

要將模塊用於 CMake,使用 find_package() 命令定位所需模塊組件在 Qt6 包:

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

要采用 qmake 構建模塊,將模塊添加作為值對於 QT 變量在工程的 .pro 文件:

QT += charts
					

各圖錶類型的錶示通過 QAbstractSeries 派生類。要創建圖錶,用戶必須使用相關係列類的實例並將它添加到 QChart 實例。

QLineSeries* series = new QLineSeries();
series->append(0, 6);
series->append(2, 4);
...
chartView->chart()->addSeries(series);
chartView->chart()->createDefaultAxes();