QCustomPlot使用手册(三)

一、改变范围

QCustomPlot *customplot;
customplot->setInteraction(QCP::iRangeDrag,true);

使控件能够拖拉。

customplot->axisRect()->setRangeDrag(Qt::Vertical);// Qt::Horizontal

使控件只能在某一方向上拖拉,默认是水平和垂直都支持。

customplot->setInteraction(QCP::iRangeZoom,true);

使控件能够伸缩。

customplot->axisRect()->setRangeZoomAxes(QCPAxis *  horizontal, QCPAxis *  vertical);

设置伸缩的坐标轴。

customplot->axisRect()->setRangeZoom();

设置伸缩的方向。默认水平和垂直都可以。

customplot->axisRect()->setRangeZoomFactor();

设置伸缩比例,可设置成一样的,也可分别对水平和垂直进行设置。

二、选择图元

customplot->setInteraction(QCP::iSelectPlottables,true);

将图元设置成可选择的。
setInteraction
在setInteraction函数中可开启的有上图这些。

customplot->graph()->setSelected(bool);

可通过setSelected设置图元能否被选中。

customplot->deselectAll();

取消所有选中。
被选中的图元的属性可通过以下设置:

QCPGraph::setSelectedPen, 
QCPGraph::setSelectedBrush, QCPAxis::setSelectedLabelFont, QCPAxis::setSelectedBasePen, QCPItemText::setSelectedColor

QCPAxis 由刻度、数值、标签组成,每部分都可以单独选中,因此通过:

customplot->xAxis->setSelectableParts();

参数可以是

 QCPAxis::spNone, QCPAxis::spAxis, QCPAxis::spTickLabels, and QCPAxis::spAxisLabel

的并集。

QCustomPlot 支持低级的响应信号,如:

QCustomPlot::mouseDoubleClick, mousePress, mouseMove, mouseRelease, and mouseWheel

以及高级的,如:

QCustomPlot::plottableClick, plottableDoubleClick, itemClick, itemDoubleClick, axisClick, axisDoubleClick, legendClick, legendDoubleClick, titleClick, and titleDoubleClick
  • 6
    点赞
  • 56
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值