在使用QCustomPlot缩放时,当缩放到所有数据点同时显示在窗口上时,再拖动图层时会十分卡顿,
卡顿的代码:
QCPGraph* _graph = m_plot->addGraph(); //添加图表
_graph->setLineStyle(QCPGraph::lsStepLeft); //设置连线类型
_graph->setPen(QPen(QColor(qrand()%255+1, qrand()%255+1, qrand()%255+1),1)); //随机颜色
_graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 3)); //显示散点数据
_graph->addData(x,y); //设置图表数据
replot(QCustomPlot::rpQueuedReplot); //刷新图表
解决方式:
- 取消显示散点,只显示连线。也就是注释如下代码
_graph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 3));
- 实测24条曲线,每条曲线13万点左右,缩放、移动流畅