首页| 论坛| 消息

标题:qcustomplot如何控制根据指定的比例缩放坐标轴
作者:zhuifengwy
日期:2016-01-13 16:19
内容:

请教一下各位大神,qcustomplot如何根据指定的比例缩放坐标轴,比如 已有一幅曲线图,
设置y轴 在现有基础上以2倍的比例进行放大或者缩小,x轴不变???


#1 [xiaoniede 05-10 22:59]
///方法1 以鼠标当前位置为中心点进行放大缩小
ui->customplot->axisRect()->setRangeZoomFactor(2);
ui->customplot->axisRect()->setRangeZoom(Qt::Vertical);
///方法2 链接mouseWheel信号进行处理(如果不以鼠标为中心,以Y轴中心点为中心)

double dCenter = ui->customplot->xAxis->range().center();
///扩大区间 (缩小 plottables 鼠标向内滚动)
ui->customplot->xAxis->scaleRange(2.0, dCenter);
///缩小区间 (放大 plotTables 鼠标向外滚动)
ui->customplot->xAxis->scaleRange(0.5, dCenter);

回复 发表
主题 版块