首页| 论坛| 消息

标题:使用QCustomPlot画曲线的问题
作者:赵小七
日期:2018-03-27 10:29
内容:

点击按钮,画出一条曲线,但是运行之后,就会卡在那,求大神看看哪错了?要调用上一个表格的lineEdit中的数据来参与for循环
//点击按钮,调用的槽函数
void calcresultdialog::on_clicked_sysPerformanceParmCalcButton()
{
//定义两个可变数组存放绘图的坐标数据
QVector x(100),y(100);//分别存放x和y坐标的数据,101为数据长度
for(double R=detectDistMin ; R < detectDistMax ; detectDistMin++)
{
x = R;
y = (targetWidth * focus)/(picSizeWidth * x);
}
//向绘图区域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();


}


#1 [wjjontheway 06-01 10:33]
楼主问题解决了吗?移动Key的值
ui->customPlot->xAxis->setRange(key+0.01, 8, Qt::AlignRight);

回复 发表
主题 版块