QcustomPlot doesn't want to plot graphs

1

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 *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 :

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

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

inline int size() const { return d->end - d->begin; }
c++
visual-studio-2010
qt
qcustomplot
asked on Stack Overflow Mar 14, 2013 by Zeus M • edited May 21, 2013 by Mat

1 Answer

-1

Please try:

x[i] = i/50 - 1;

It's working fine

answered on Stack Overflow Feb 21, 2017 by sumeet • edited Feb 21, 2017 by Draken

User contributions licensed under CC BY-SA 3.0