QCustomPlot用法

一、导入QTCreator

  将qcustomplot.c qcustomplot.h 文件导入项目文件夹

  并在工程文件加入 QT += printsupport

  在QT 设计师界面,在主窗口加入一个Widget组件,并右键选中,选中 提升为...,添加QCustomPlot类

 

 

  之后组建,编译,即可出现默认的坐标系。在主函数文件当中,可以实验ui->widget去访问qcustomplot对象

 

 

 

 

二、基本用法

2.1 设置坐标系

1 mPlot->xAxis->setRange(-6.0, 6.0);
2 mPlot->yAxis->setRange(0, 12.0);
3 mPlot->addGraph(mPlot->yAxis, mPlot->xAxis);

2.2 设置画笔

QPen drawPen;
drawPen.setColor(Qt::gray);
drawPen.setWidth(1);
drawPen.setStyle(Qt::DashLine);
mPlot->graph(0)->setPen(drawPen);

 

 

三、进阶用法

posted @ 2019-09-02 17:40  hanabic  阅读(1120)  评论(0编辑  收藏  举报