• 3346阅读
  • 1回复

[提问]使用QCustomPlot画曲线的问题 [复制链接]

上一主题 下一主题
离线赵小七
 

只看楼主 倒序阅读 楼主  发表于: 2018-03-27
点击按钮,画出一条曲线,但是运行之后,就会卡在那,求大神看看哪错了?要调用上一个表格的lineEdit中的数据来参与for循环

//点击按钮,调用的槽函数
void calcresultdialog::on_clicked_sysPerformanceParmCalcButton()
{
     //定义两个可变数组存放绘图的坐标数据
    QVector<double> x(100),y(100);//分别存放x和y坐标的数据,101为数据长度
    for(double R=detectDistMin ; R < detectDistMax ; detectDistMin++)
    {    
        x[R] = R;
        y[R] = (targetWidth * focus)/(picSizeWidth * x[R]);
    
    }
//向绘图区域QCustomPlot(从widget提升来的)添加一条曲线

   ui.qCustomPlot->addGraph();

   //添加数据
   ui.qCustomPlot->graph(0)->setData(x,y);

  //设置坐标轴标签名称
   ui.qCustomPlot->xAxis->setLabel("x");
   ui.qCustomPlot->yAxis->setLabel("y");

   //设置坐标轴显示范围,否则我们只能看到默认的范围
   ui.qCustomPlot->rescaleAxes();


    
    
    
}
离线wjjontheway

只看该作者 1楼 发表于: 2018-06-01
楼主问题解决了吗?移动Key的值
ui->customPlot->xAxis->setRange(key+0.01, 8, Qt::AlignRight);
快速回复
限100 字节
 
上一个 下一个