Important: Please read the Qt Code of Conduct -

Do the Canvas has contextReady event?

  • Hi everybody,
    I have two canvas element in my project and I have to know two contexts are available before the start drawing. When I use "oncomplete" event handler, I realized that context is not ready at this moment.

           Canvas {
            id: b
            anchors.fill: parent
            onPaint: {
            Component.onCompleted: {
                console.log("b completed : "+b.getContext("2d"));

    Only I can get the context at first onpaint event. How can I know two context ready and start the drawing without first onpaint event check?

  • Qt Champions 2017

    You can use available property like the following.

    onAvailableChanged: {
                    if (available==true){
                        console.log(" Available changed -  "+b.getContext('2d'));
                    }else {
                        console.log(" Available is not changed")

  • @dheerendra
    Thank you. I tried it and worked as expected.

Log in to reply