Solved add one million points to a series,
-
I want to paint a curve of one million point ,but the program always crush.the reason is
Out of memory in ....\include/QtCore/../../src/corelib/tools/qvector.h, line 564
terminate called without an active exceptionthe code:
chart = new QChart(); series = new QSplineSeries(); for (long long i = 0; i < 1000000; i++) { series->append(i, 60); } chart->legend()->hide(); chart->addSeries(series); QValueAxis *_pValueAxisH = new QValueAxis(); _pValueAxisH->setMin(0); _pValueAxisH->setMax(1000000); _pValueAxisH->setGridLineVisible(false); _pValueAxisH->setTickCount(2); _pValueAxisH->setLinePenColor(QColor(Qt::darkBlue)); QValueAxis *_pValueAxisV = new QValueAxis(); _pValueAxisV->setMin(0); _pValueAxisV->setMax(75); _pValueAxisV->setGridLineVisible(false); _pValueAxisV->setTickCount(6); _pValueAxisV->setLinePenColor(QColor(Qt::darkBlue)); chart->addAxis(_pValueAxisH, Qt::AlignBottom); chart->addAxis(_pValueAxisV, Qt::AlignLeft); chart->setContentsMargins(0, 0, 0, 0); chart->setMargins(QMargins(0, 0, 0, 0)); chart->setBackgroundRoundness(0); series->attachAxis(_pValueAxisH); series->attachAxis(_pValueAxisV); ui->graphicsView->setChart(chart); ui->graphicsView->setRenderHint(QPainter::Antialiasing);
-
Hi and welcome to devnet,
Please provide a minimal compilable example that triggers this behavior.
Also:
- which version of Qt are you using ?
- on which OS ?
- 32 or 64 bit ?
-
Don't do it. Noone can distinguish them anyway.
-
@amwps290 said in add one million points to a series,:
I want to paint a curve of one million point
Why? Why do you think your curve needs so many points? It would be more efficient to reduce the amount of points as nobody will be able to see the difference.
Why do you use long long as data type for your points? -
thank you for your reply.
the environemnt:
OS: win10 2004
Qt Version: 5.12.9The first time I used a 32-bit environment, and then I installed a 64-bit environment, but this problem did not occur
-
So it did only occur in 32bit mode ? So it means that you are using way too much data.
As my fellows already wrote: 1 million points does not make sense to be shown as is.
-
@SGaist Thank you! I will reduce the acount of data point