首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >QcustomPlot不想绘制图表

QcustomPlot不想绘制图表
EN

Stack Overflow用户
提问于 2013-03-14 18:29:00
回答 1查看 3K关注 0票数 1

我是QCustomPlot的新手,我想开始QCustomPlot的第一个例子,这是关于基本用法的。在下面的代码中:我总是有一个断点,它会在程序将要调试时停止它(没有错误,构建也成功完成)

代码语言:javascript
运行
复制
QCustomPlot *customPlot;

QVector<double> x(101), y(101); 
for (int i=0; i<101; ++i) {
  x[i] = i/50.0 - 1; // x goes from -1 to 1
  y[i] = x[i]*x[i]; // let's plot a quadratic function
}
customPlot->addGraph();
customPlot->graph(0)->setData(x, y);
customPlot->xAxis->setLabel("x");
customPlot->yAxis->setLabel("y");
customPlot->xAxis->setRange(-1, 1);
customPlot->yAxis->setRange(0, 1);
customPlot->replot();

}

显示的错误为:

代码语言:javascript
运行
复制
Unhandled exception at 0x58e828f1 (QtCored4.dll) in ex4.exe: 0xC0000005: 
Access violation reading location 0x00000050.

断点在这里(QList.h文件):

代码语言:javascript
运行
复制
inline int size() const { return d->end - d->begin; }
EN

回答 1

Stack Overflow用户

发布于 2017-02-21 16:25:27

请尝试:

代码语言:javascript
运行
复制
x[i] = i/50 - 1;

它工作正常

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15406694

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档