Important: Please read the Qt Code of Conduct -

Any tricks to increase QtChart responsiveness?

  • Hi! I need to make a line plot of a large amount of data in a short period of time. The goal is to have 100,000 data points plotted in a line series in less than 50 milliseconds. I am able to do this through QPainterPath by painting on a QWidget, but I would like to give QtChart another shot because the QXYSeries class involves some basic interactions that I am unable to implement otherwise through QPainterPath. To check the responsiveness of the QtChart I made a small test application, here is the entire code for that:


    #include <QtWidgets/QMainWindow>
    #include <QtCharts/qchartview.h>
    #include <QtCharts/qlineseries.h>
    #include <QtMath>
    #include <QElapsedTimer>
    #include <QDebug>
    #include "ui_mainWindow.h"
    using namespace QtCharts;
    class mainWindow : public QMainWindow
        mainWindow(QWidget *parent = Q_NULLPTR);
        Ui::mainWindowClass ui;
        QLineSeries *series;
        QChartView *view;
        QChart *chart;
        double data;
        virtual void resizeEvent(QResizeEvent *event) override;


    #include "mainWindow.h"
    mainWindow::mainWindow(QWidget *parent)
        : QMainWindow(parent)
        /* Creating Line Series */
        series = new QLineSeries();
        for(int ii = 0; ii < 100000; ++ii)
            data = 2 * sin(2 * M_PI * 3 * ii / 100000);
            *series << QPointF(ii, data);
        /* Creating Chart */
        chart = new QChart();
        /* Creating Chart View */
        view = new QChartView(chart);
    void mainWindow::resizeEvent(QResizeEvent *event)
        QElapsedTimer timer;
        chart->resize(width(), height());
        qDebug() << timer.elapsed() << "milliseconds";

    I am getting a response time of more than 500 milliseconds. I have already disabled all animations. Is there any way I can improve this response time significantly?

    For reference, I am using Qt 5.15.0 with Visual Studio Community 2019.

  • Lifetime Qt Champion


    Likely not the answer you are looking for but you might want to check the Qwt project. It may have better performance for that kind of cases.

  • @SGaist Thanks! I have considered Qwt Project, however, it doesn't have proper documentation to tell me if it has the interactions that I need. On top of that, I am quite sure plotting the same amount of data on Qwt will take upwards of 100 milliseconds which is still beyond the limits of my requirements.

  • @CJha

    Nobody can look at 100.000 data points.
    Use downsampling to reduce the amount of points shown at a time. While zooming in or so, you can increase that amount again until you show that area with all the data.

  • @Pl45m4 I know, I have developed my own method of downsampling for a line plot, so that peaks and overall data values are preserved. I can use it with QWidget and draw there much faster (15 - 20 ms). However, even if I use the raw method of plotting all the data points in QWidget it takes slightly more than 100 milliseconds, the same raw method in QChart takes between 500 - 600 milliseconds.

  • Moderators

    @CJha Charts is far from optimized, especially the QWidget version, have you tried a QQuickWidget/View and the QML Chart view?

    usually results in better overall performance

  • @J-Hilk Thanks for the suggestion.
    I haven't tried it, I am working with C++ only. As far as I understand for Qt Quick I will have to use QML which I haven't learned yet (I started with C++ a few a month back). Hopefully, the Qt 6 release in December this year will bring huge improvements to Qt Charts.