QcustomPlot不希望绘制图形。

时间:2022-07-25 18:46:17

I'm newbie in QCustomPlot and wanted to start the first example of QCustomPlot which is about a basic usage. In the following code: I always have a break point which stops the program when it's about to debug (no errors and building is successfully done)

我是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();

}

}

The displayed erroris :

显示erroris:

Unhandled exception at 0x58e828f1 (QtCored4.dll) in ex4.exe: 0xC0000005: 
Access violation reading location 0x00000050.

The break point is in here (QList.h file):

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

inline int size() const { return d->end - d->begin; }

1 个解决方案

#1


-1  

Please try:

请尝试:

x[i] = i/50 - 1;

It's working fine

它工作正常

#1


-1  

Please try:

请尝试:

x[i] = i/50 - 1;

It's working fine

它工作正常