ui->customPlot->legend->setVisible(false);
ok,以上便是本文的全部内容了,如果对你有所帮助,记得点个赞哟~
目录1、前言2、方法一3、方法二1、前言2、方法一int QCustomPlot::clearGraphs()从plot中删除所有graphs并将其删除。相应的图例项也将从默认图例(QCustomPlot::legend)中删除。该函数接受一个int类型的返回值,返回删除的graphs数。代码示例:ui->customPlot->clearGraphs();清空结果:3、方法二clearPlottables...
讲解都在注释中 qcustomplot.pro#-------------------------------------------------
# Project created by QtCreator 2018-03-09T14:50:00
#-------------------------------------------------
QT += core gu...
1.添加、删除图层
添加图层:如果keyAxis和valueAxi为空,则底部(xAxis)用作键,左边(yAxis)用作值轴;如果指定,keyAxis和valueAxis必须位于QCustomPlot中
QCPGraph *addGraph(QCPAxis *keyAxis=nullptr, QCPAxis *valueAxis=nullptr)
bool removeGraph(QCPGraph *graph)
2.设置画笔、画刷
下面这段代码,添加了两个图层,分别设置画笔和
QChart实现了各种各样的曲线,饼状图,柱状图等等,综合了之前的第三方图表模块QCustomPlot, QWT的功能,这两种也是很好的Qt图表类库。QChart在5.7之前只有商业版才有,5.7之后社区版也可以使用了。建议使用Qt5.7之后的版本,在安装的时候勾选QCharts模块,不然无法使用该功能。
QChart demo代码在Qt的安装路径:D:\Qt5....
// 添加数据到曲线
for(int i = 0; i < dataVector.size(); i++) {
graph->addData(dataVector.at(i).x, dataVector.at(i).y);
// 显示图形
customPlot->replot();