Important: Please read the Qt Code of Conduct -

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 exception

    the code:

    chart = new QChart();
        series = new QSplineSeries();
        for (long long i = 0; i < 1000000; i++)
            series->append(i, 60);
        QValueAxis *_pValueAxisH = new QValueAxis();
        QValueAxis *_pValueAxisV = new QValueAxis();
        chart->addAxis(_pValueAxisH, Qt::AlignBottom);
        chart->addAxis(_pValueAxisV, Qt::AlignLeft);
        chart->setContentsMargins(0, 0, 0, 0);
        chart->setMargins(QMargins(0, 0, 0, 0));

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Please provide a minimal compilable example that triggers this behavior.


    • which version of Qt are you using ?
    • on which OS ?
    • 32 or 64 bit ?

  • Lifetime Qt Champion

    Don't do it. Noone can distinguish them anyway.

  • Lifetime Qt Champion

    @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?

  • @SGaist

    thank you for your reply.

    the environemnt:

    OS: win10 2004
    Qt Version: 5.12.9

    The first time I used a 32-bit environment, and then I installed a 64-bit environment, but this problem did not occur

  • Lifetime Qt Champion

    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

Log in to reply