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! :)