我是QCustomPlot的新手,我想开始QCustomPlot的第一个例子,这是关于基本用法的。在下面的代码中:我总是有一个断点,它会在程序将要调试时停止它(没有错误,构建也成功完成)
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();}
显示的错误为:
Unhandled exception at 0x58e828f1 (QtCored4.dll) in ex4.exe: 0xC0000005:
Access violation reading location 0x00000050.断点在这里(QList.h文件):
inline int size() const { return d->end - d->begin; }发布于 2017-02-21 16:25:27
请尝试:
x[i] = i/50 - 1;它工作正常
https://stackoverflow.com/questions/15406694
复制相似问题