QCustomPlot was used as an aid for drawing graphics in Qt Creator (installed correctly as the example was compiled)
inline double fn(int T, double x) { if (x >= 0) return T; return 0; } void MainWindow::drawfunc(int valT, int xmin, int xmax) //ΠΡΠ²ΠΎΠ΄ ΡΡΠ½ΠΊΡΠΈΠΈ Π₯ΡΠ²ΠΈΡΠ°ΠΉΠ΄Π° { double hh =0.01; int N = (xmax-xmin)/hh;//ΡΡΠΈΡΠ°Π΅ΡΡΡ ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΡΠΎΡΠ΅ΠΊ Π΄Π»Ρ ΠΌΠ°ΡΡΠΈΠ²ΠΎΠ² ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ xmax=10,xmin=-5 ΠΈΡΠΎΠ³ΠΎ 1500 QVector<double> x11(N), y11(N); // //ΠΠ°ΡΡΠΈΠ²Ρ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ ΡΠΎΡΠ΅ΠΊ int i=0; for (double x = xmin; x < xmax; x +=hh) { x11[i]=x; y11[i]=fn(valT,x); i++; } ui->widget->clearGraphs(); ui->widget->addGraph(); ui->widget->graph(0)->setData(x11, y11); // Π·Π°Π΄Π°Π΅ΠΌ ΠΈΠΌΠ΅Π½Π° ΠΎΡΠ΅ΠΉ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°Ρ ui->widget->xAxis->setLabel("x"); ui->widget->yAxis->setLabel("y"); // Π·Π°Π΄Π°Π΅ΠΌ ΡΠ°Π·ΠΌΠ΅ΡΡ ΠΎΡΠ΅ΠΉ ui->widget->xAxis->setRange(xmin, xmax); ui->widget->replot(); } The problem is that the graph is not drawn, an exception crashes.
ASSERT failure in QVector<T>::operator[]: "index out of range", file ..\..\..\..\Qt\5.3\mingw482_32\include/QtCore/qvector.h, line 385 Step by step during debugging it turned out that:
- problem due to QVector
The number of points is 1500 (manual formula calculation), Qt Creator produces 1499.
Such simple techniques as
int N = ((xmax-xmin)/hh)+1 ΠΈΠ»ΠΈ `QVector<double> x11(N+1), y11(N+1)` `i=1` also give an exception ..

