文章目录
QCustomplot
QCPAxis 描述轴行为,轴需要依赖QCPAxisRect
QCPAxisRect 描述矩形区域,区域依赖于QCPCustomPlot
QCPLayoutGrid 网格形排列矩形区域,类似于QGridLayout
QCustomPlot 默认行为及对象
QLegend 图例
方法
- add函数
void QCPGraph::addData(double key, double value, bool setDirty = true);
// 创建实例
QCPGraph *graph = customPlot->addGraph();
// 添加数据点, 实时更新
graph->addData(1.0, 2.0, true); // 立即更新绘制
// 在批量添加后统一更新图形
graph->addData(2.0, 4.0, false); // 不立即更新绘制
// 批量添加完成后,再进行更新
customPlot->replot(); // 仅在最后一次调用更新图形
QCustomPlot的几个重要类
QCustomPlot 图表类:用于图表的显示和交互;
QCPLayer 图层:管理图层元素(QCPLayerable)
QCPLayerable图层元素:所有可显示的对象都是继承自图层元素;