How to speed up access to QList<qreal> exposed from C++ to QML



  • Hi,
    I have some problem with speed to access to QList<qreal> property.
    I have declared
    @ Q_PROPERTY(QList<qreal> circlePointsX READ circlePointsX NOTIFY circlePointsXChanged);
    QList<qreal> circlePointsX(void) const
    {
    return mCirclePointsX;
    }@

    and in QML file, i made

    @ pArea.circlesPointsX = paintAreaHelper.circlePointsX;
    @

    and after that some code is reading point by point
    @
    var cPointsX = circlesPointsX;
    var cPointsY = circlesPointsY;

        var noOfPoints = circlesPointsX.length - 4;
        for (var i = 0; i <= noOfPoints; i+=4)
        {
    
            ctx.moveTo(cPointsX[i], cPointsY[i]);
            ctx.lineTo(cPointsX[i+1], cPointsY[i+1]);
            ctx.lineTo(cPointsX[i+2], cPointsY[i+2]);
            ctx.lineTo(cPointsX[i+3], cPointsY[i+3]);
            ctx.lineTo(cPointsX[i], cPointsY[i]);
    
    
        }
    

    @

    of course the type of property is var
    @ property var circlesPointsX;@

    and asigmen
    @ var cPointsX = circlesPointsX;@

    does not spped up anything, because it's just copying the reference....

    I debug it, and for every signle acces, the c++ method is called.
    I would like to copy the data from c++ once and access it from "local qml copy" instead of calling getter every time....

    Thank you in advance
    Krzysiek


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.