• 3574阅读
  • 1回复

[提问]QCustomplot怎么拖拽最大范围和缩放的最大比例 [复制链接]

上一主题 下一主题
离线solo_wang
 

只看楼主 倒序阅读 楼主  发表于: 2019-05-17
回复本帖可获得10RMB金钱奖励!
每人最多可获奖1次,奖池剩余20RMB金钱 (中奖几率100%)
  1. ui->customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
QCustomplot设置了允许托拽和缩放,用官方的demo发现,左右托拽可以超过setRange()设置的范围,可以一直拖至无限小,缩放也是可以缩放到无限小。
各位大侠,有没有什么办法,可以设置托拽的范围,和缩放比例?
离线mrbmrb

只看该作者 1楼 发表于: 2019-09-01
回帖奖励+ 10
我给个参考方法。设置 缩放和拖拽事件,然后,在事件里面设置 xAxis 和 yAxis 最大和最小范围

    connect(ui.customPlot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
    connect(ui.customPlot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));

void RepairWorkbench::mouseWheel()
{
    ui.customPlot->yAxis->setRangeLower(0);
    ui.customPlot->yAxis->setRangeUpper(500.0);
    ui.customPlot->xAxis->setRangeLower(0);
快速回复
限100 字节
 
上一个 下一个