Qt Charts C++ Classes

Qt Charts API 的 C++ 类。更多

QAbstractAxis

用于专门轴类的基类

QAbstractBarSeries

所有条形图系列类的抽象父类

QAbstractSeries

所有 Qt Charts 系列的基类

QAreaLegendMarker

区域系列的图例标记

QAreaSeries

在区域图表中显示数据

QBarCategoryAxis

为图表坐标轴添加类别

QBarLegendMarker

条形图系列的图例标记

QBarSeries

将一系列数据显示为按类别分组的垂直条形图

QBarSet

代表条形图中的一组条形

QBoxPlotLegendMarker

方框图系列的图例标记

QBoxPlotSeries

以盒须图显示数据

QBoxSet

表示箱形须线图中的一个项目

QCandlestickLegendMarker

蜡烛图系列的图例标记

QCandlestickModelMapper

烛台数列的抽象模型映射器类

QCandlestickSeries

将数据显示为烛台

QCandlestickSet

表示烛台图中的单个烛台项目

QCategoryAxis

在坐标轴上放置命名范围

QChart

管理图表系列、图例和坐标轴的图形显示

QChartView

可显示图表的独立部件

QColorAxis

将色标显示为图表坐标轴之一

QDateTimeAxis

在图表坐标轴上添加日期和时间

QHBarModelMapper

条形图的水平模型映射器

QHBoxPlotModelMapper

方框图系列的水平模型映射器

QHCandlestickModelMapper

蜡烛图系列的水平模型映射器

QHPieModelMapper

饼图系列的水平模型映射器

QHXYModelMapper

线形、样条线形和散点图系列的水平模型映射器

QHorizontalBarSeries

将一系列数据显示为按类别分组的水平条形图

QHorizontalPercentBarSeries

将一系列分类数据显示为每个类别的百分比

QHorizontalStackedBarSeries

将一系列数据显示为水平堆叠的条形图,每个类别一个条形图

QLegend

显示图表图例

QLegendMarker

抽象对象,可用于访问图例中的标记

QLineSeries

以折线图显示数据

QLogValueAxis

在图表坐标轴上添加对数刻度

QPercentBarSeries

以每个类别的百分比显示分类数据系列

QPieLegendMarker

饼图系列的图例标记

QPieSeries

在饼图中显示数据

QPieSlice

表示饼系列中的单个切片

QPolarChart

在极坐标图中显示数据

QScatterSeries

以散点图表示数据

QSplineSeries

以曲线图表示数据

QStackedBarSeries

以垂直堆叠的条形图表示数据系列,每个类别一个条形图

QVBarModelMapper

条形图系列的垂直模型映射器

QVBoxPlotModelMapper

箱形图系列的垂直模型映射器

QVCandlestickModelMapper

蜡烛图系列的垂直模型映射器

QVPieModelMapper

饼图系列的垂直模型映射器

QVXYModelMapper

线形、样条线形和散点图系列的垂直模型映射器

QValueAxis

为图表坐标轴添加数值

QXYLegendMarker

直线、样条线或散点图系列的图例标记

QXYSeries

直线、样条线和散点图系列的基类

详细说明

图表 API 建立在 Qt 图形视图框架之上。使用QChart 类可将图表显示为QGraphicsWidget 。不过,还有一个基于QWidget 的便利类QChartView 。这些使我们能快速地将Qt Charts 用作普通的 Qt Widgets。

注意: Qt Charts 模块正处于维护阶段。对于新项目,请考虑使用 Qt Graphs模块。要呈现 2D 图表,QtGraphs 使用 Qt Quick Shapes,与Qt Charts 模块使用的过时的 Qt Graphics View Framework 相比,Qt Graphics View Framework 是一种更现代的图形用户界面技术。

使用 Qt 模块的 C++ API 需要直接或通过其他依赖关系与模块库链接。一些构建工具(包括 CMake 和 qmake)对此提供了专门支持。

注: 使用Qt CreatorQt Quick Application 向导创建的项目基于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 制作模块,可在项目的 .pro 文件中将模块添加为QT 变量的值:

QT += charts

每种图表类型都由QAbstractSeries 派生类表示。要创建图表,用户必须使用相关系列类的实例,并将其添加到QChart 实例中。

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

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