Important: Please read the Qt Code of Conduct -

QSGGeometry / scenegraph: how to reuse data from QSGGeometry

  • Hi,

    I am using scenegraph to generate a chart and so each x ms I get a new data sample from the input module. Now I regenerate the data constantly using a for loop:
    QSGGeometry* geometryNewLine = mNodeNewLine->geometry();
    QSGGeometry::ColoredPoint2D *verticesNewLine = geometryNewLine->vertexDataAsColoredPoint2D();

        for (int i=0; i<mLoopVertices->newLineVertices.count(); i++)
            color = mLoopVertices-> ? colorInspiration : colorExpiration;
            verticesNewLine[i].set(//adapt vertice
                                   mLoopVertices->, mLoopVertices->,
                                   //adapt color
                         ,,, color.alpha()

    But this is taking quite some time and performance of course ... now I do not seem to see in the documentation a method for updating this with one new sample at the time? Do I always need to copy everything?

    A immediate easy update could be using a QVector in code outside of the updatePaintNode and then get the data as an array out of it and doing a memcopy or some sort (std::copy).

    Still I wonder if there is not an easier way of updating part of the data through QSGGeometry instead of always copying everything,

    thanks in advance,

    kind regards,


    [edit, code tags added, koahnig]

  • Please check out the "code wrapping section": in the forum help. This helps to make your code more readable in the forum.

Log in to reply