Important: Please read the Qt Code of Conduct -

Controlling QML: canvas2D with 2 buttons

  • Hi Everyone,
    Am using one buttons in QML to control my canvas(circular progress ).
    On pressing button am able to create that circular progress bar perfectly.
    But once that progress bar is completed it remains there on screen and i want to use reset it and draw again one that button press again.
    Already tried reset function and clearRect but not acheive my aim.
    Anybody know how to do this stuff.

  • @aks17

    Just for testing. Instead of using clear rect try a fillRect with bright red as your clear colour. You'll soon get an idea of whether that worked or not.

    Also, if you could provide a smallish code snippet that would help.

  • Moderators

    hi @aks17

    inside your canvas, define a property bool propter, clearCanvas or something.

                    anchors.fill: parent
                    property bool clearCanvas : false
                    onClearCanvasChanged: canvas.requestPaint()
                    onPaint: {
                       var ctx = getContext("2d");
                            clearCanvas = false;
                      //Your normal paint stuff goes hear

    reset() removed all previous drawings.

Log in to reply