QtCharts模块在QtWideget中图表绘制(非QML)

博客地址已更改,文章数量较多不便批量修改,若想访问源文请到 coologic博客 查阅,网址:www.coologic.cn

如本文记录地址为 techieliang.com/A/B/C/ 请改为 www.coologic.cn/A/B/C/ 即可查阅

版权声明:若无来源注明,Techie亮博客文章均为原创。 转载请以链接形式标明本文标题和地址:
本文标题:QtCharts模块在QtWideget中图表绘制(非QML)     本文地址:http://techieliang.com/2017/12/724/

1. 介绍

以前一直用QCustomPlot,现在Qt提供了QtCharts,看起来效果比,模块的帮助文档:QtCharts,所有官方的范例:Example

2. QChart

提供了三个枚举类型

enum AnimationOption { NoAnimation, GridAxisAnimations, SeriesAnimations, AllAnimations }
enum ChartTheme { ChartThemeLight, ChartThemeBlueCerulean, ChartThemeDark, ChartThemeBrownSand, …, ChartThemeQt }
enum ChartType { ChartTypeUndefined, ChartTypeCartesian, ChartTypePolar }

分别用于定义动画效果、背景风格、以及图标类型是极坐标还是笛卡尔,对于风格方面请见范例Chart Themes Example

Animation不会自己播放,需要在图标刷新时有用,一个是坐标轴和图标网格线一个是series,比如柱状图逐渐升起的过程,最简单的刷新方法:改窗口尺寸

除此以外通过接口可以操作title标题、axis坐标轴,并通过addSeries添加图

3. 其他

  • 建议使用Mapper映射到model中,通过修改model可以动态调整表格
  • QtCharts的new出的对象都会在add、set以后由上一级管理,不需要主动delete
转载请以链接形式标明本文标题和地址:Techie亮博客 » QtCharts模块在QtWideget中图表绘制(非QML)
原文地址:https://www.cnblogs.com/techiel/p/8057454.html