本页内容

带小部件的图表图库

一款演示Qt Charts 小部件API的应用程序。

截图显示了一张柱状图,展示了1月至12月这12个月内温度记录,范围在52摄氏度至-52摄氏度之间,正温度区域的柱状图为绿色,负温度区域的柱状图为蓝色。左侧提供了多种选项,可用于将图表切换为不同的图表类型。

本示例通过使用内置的示例数据,为用户展示多种图表类型和交互方式,从而演示Qt Charts 控件API。

Changing the Color and State of Bars

演示了如何为条形图使用选择功能。

Combining Line and BarChart

演示了如何组合不同的图表并设置坐标轴。

Creating Area Charts

演示了如何创建一个简单的面积图。

Creating Bar Charts

BarChart 将数据按类别以独立条形的形式分组显示。

Creating Box-and-Whiskers Charts

演示如何创建箱线图。

Creating Candlestick Charts

演示如何创建 K 线图。

Creating Charts With Themes

展示了不同内置主题的外观和风格。

Creating Horizontal Bar Charts

演示如何创建水平条形图。

Creating Horizontal Percent Bar Charts

演示如何创建一个简单的水平百分比条形图。

Creating Horizontal Stacked Bar Charts

演示如何创建简单的堆积式水平条形图。

Creating Line Charts

演示如何创建一个简单的折线图。

Creating Nested Donut Charts

演示如何使用 QPieSeries API 创建嵌套环形图。

Creating Percent Bar Charts

演示如何创建一个简单的百分比柱状图。

Creating Polar Charts

演示如何创建包含多个不同数据列的简单极坐标图。

Creating Scatter Charts

该示例演示了如何创建一个简单的散点图。

Creating Stacked Bar Charts

演示如何创建一个简单的堆积条形图。

Creating a Donut Breakdown Chart

演示如何创建环形分解图。

Customizing Charts

演示如何自定义图表元素的外观。

Detaching and Attaching Legends

演示如何将图例从图表中分离,然后重新附加。

Displaying Temperature Records with Negative Bars

演示如何创建包含负值柱的柱状图。

Drawing a Callout on Top of a Chart

演示如何在图表上方绘制额外元素(标注)。

Implementing Drilldown

演示如何使用堆叠条形图实现钻取功能。

Line Charts with Date and Time Axes

演示如何将 QLineChart 与 QDateTimeAxis 结合使用。

Selected Point Configuration

演示如何修改单个数据点的配置。

Using Data Models with Bar Charts

演示如何将 QAbstractItemModel 的派生模型用作条形系列的数据。

Using Legend Markers

演示如何使用图例标记。

Using Light Markers and Points Selection

演示如何为一个系列使用浅色标记和点选择功能。

Using Logarithmic Value Axes

演示如何使用 QLogValueAxis。

Using Model Data

演示如何将从 QAbstractItemModel 派生的模型用作系列数据。

Using Multiple Axes

演示如何创建一个每个系列都有独立纵轴的图表。

运行示例

您可以通过以下方式运行示例:

如果您想使用 QML 实现图表,请参阅“使用 QML 实现图表”示例库。

示例项目 @ code.qt.io

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