簡體   English   中英

QcustomPlot不想繪制圖形

[英]QcustomPlot doesn't want to plot graphs

我是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; }

請試試:

x[i] = i/50 - 1;

一切正常

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM