QCustomPlot绘图控件的使用
来源:互联网 发布:officeim网络办公 编辑:程序博客网 时间:2024/06/05 01:47
前段时间因一个项目的绘图需要,开始学习QCustomPlot的使用,总体来说是非常容易上手的,而且强大的绘图功能应该能满足多数专业绘图的需要了。
(源文件下载地址:http://www.qcustomplot.com/index.php/download)
1、怎样配置使用就不细说了,官网上代码和文档都是有的
2、关键函数与设置属性的介绍
//设置显示的大小和位置
ui->PressDraw->setGeometry(QRect(30,30,650,350));
//设置需要显示的坐标轴,
ui->PressDraw->xAxis2->setVisible(true);
ui->PressDraw->xAxis2->setTickLabels(true);
ui->PressDraw->xAxis->setVisible(false);
ui->PressDraw->xAxis->setTickLabels(false);
//添加箭头
ui->PressDraw->xAxis2->setUpperEnding(QCPLineEnding::esSpikeArrow);
ui->PressDraw->yAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
//纵坐标反转找了好久才知道这个函数
ui->PressDraw->yAxis->setRangeReversed(true);
//设置坐标轴单位名称
ui->PressDraw->xAxis2->setLabel(codec->toUnicode("压力(MPa)"));
//右上标签显示ui->PressDraw->legend->setVisible(true);ui->PressDraw->legend->setFont(QFont("Helvetica",9));ui->PressDraw->legend->setBrush(QBrush(QColor(255,255,255,210)));//210透明度ui->PressDraw->legend->setSelectableParts(QCPLegend::spItems);ui->PressDraw->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignRight);//标签位置//移动和放缩ui->PressDraw->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);//向绘图区域QCustomPlot添加一条曲线ui->PressDraw->addGraph(ui->PressDraw->yAxis,ui->PressDraw->xAxis);ui->PressDraw->graph(i)->setData(y,x);//绘图的数据ui->PressDraw->graph(i)->setName(codec->toUnicode("曲线%1").arg(i));ui->PressDraw->graph(i)->setScatterStyle(m_StyleChoice.at(i));//点样式ui->PressDraw->graph(i)->setPen(m_PenChoice.at(i));//画笔ui->PressDraw->graph(i)->rescaleAxes();//重绘
3、很多标签是有槽函数的,可根据需要进行编写。比如可以通过点击“深度”,实现单位换算。以及右上标签"曲线0",实现需要的功能,我这里是点击实现数据的更改和查看。这里列出一些槽函数作参考。
//双击修改坐标轴标签设置单位
connect(ui->PressDraw, SIGNAL(axisDoubleClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)),
this, SLOT(axisLabelDoubleClick_Press(QCPAxis*,QCPAxis::SelectablePart)));
-----------------------------------------------------------------------------------------
//点击曲线显示曲线参数信息
connect(ui->PressDraw, SIGNAL(plottableClick(QCPAbstractPlottable*,QMouseEvent*)),this, SLOT(LineDoubleClick_Press(QCPAbstractPlottable*)));-----------------------------------------------------------------------------------------
//右键保存图像(很重要,根据设置将图像保存为自己需要的图片格式)ui->PressDraw->setContextMenuPolicy(Qt::CustomContextMenu);connect(ui->PressDraw, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(PresscontextMenuRequest(QPoint)));//槽函数代码void simulationPT::PresscontextMenuRequest(QPoint pos){
QTextCodec *codec = QTextCodec::codecForName("GB18030");QMenu *menu = new QMenu(this);menu->setAttribute(Qt::WA_DeleteOnClose);if (ui->PressDraw->legend->selectTest(pos, false) < 0){menu->addAction( codec->toUnicode("保存图片"), this, SLOT(PressSaveGraph()));}menu->popup(ui->PressDraw->mapToGlobal(pos));}
-----------------------------------------------------------------------------------------//点击右上标签编辑数据connect(ui->PressDraw, SIGNAL(legendDoubleClick(QCPLegend*,QCPAbstractLegendItem*,QMouseEvent*)), this,SLOT(legendDoubleClick_Press(QCPLegend*,QCPAbstractLegendItem*)));
0 0
- QCustomPlot绘图控件的使用
- 使用QCustomPlot绘图的基础
- 关于QCustomPlot的绘图
- 关于Qt绘图控件qCustomPlot
- Qt绘图控件QCustomPlot安装
- QCustomPlot绘图(一):使用入门
- QCustomPlot之绘图的基础
- QCustomPlot之绘图的基础
- QCustomPlot绘图
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- [转] QT超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- 【个人收藏】qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- 转:qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- 黑马程序员—【Java基础篇】之多态、内部类、异常及包
- modelsim 直接创建仿真,而不是从Quartus II 或者 Vivado 仿真
- Swift ImageView图像视图
- MySql体系结构
- 首次体验VS
- QCustomPlot绘图控件的使用
- 解决存到数据库里中文乱码问题
- 使用Spring MVC统一异常处理实战
- C++窗口程序设计(计算三角形的周长和面积)
- NotificationDownLoad 通知栏显示下载进度
- visual studio生成的文件都是啥
- ScrollView起始位置不是最顶部
- 作业3.1
- 集合类说明及区别