1

I need to capture an image from QML which has Canvas elements. Whereas Canvases are displayed fine they are not correctly saved in the picture snapshots.

I have used QQuickWindow grabWindow method as described in the solutions of this link and the images are saved in the UI thread called by afterRendering signal (I have tried frameSwapped signal too). Result is that all QML objects are saved but not Canvas objects.

Both the renderStrategy and renderTargetof Canvases are set to the default values. They are simple Canvases as shown below:

Canvas {
    id:canvas

    onPaint:{
        var ctx = canvas.getContext('2d');
        ctx.beginPath();
        ctx.moveTo(20, 0);
        ctx.bezierCurveTo(-10, 90, 210, 90, 180, 0);
        ctx.stroke();
        //...
    }
}

I have noticed that the afterRendering signal is called multiple times.

Any suggestion is really appreciated! :)

Community
  • 1
  • 1
  • 1
    Stab in the dark here... have you tried a different [renderStrategy](http://doc.qt.io/qt-5/qml-qtquick-canvas.html#renderStrategy-prop) and/or [renderTarget](http://doc.qt.io/qt-5/qml-qtquick-canvas.html#renderTarget-prop)? – Mitch Jul 22 '15 at 17:45
  • I have tried Threaded for renderStrategy with no results but the doc says: "Canvas.Immediate - context will perform graphics commands immediately in the main UI thread." so I believe it should be immediate. I can try the other renderTarget. – neoterryjoe Jul 23 '15 at 07:03

0 Answers0