Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Controlling QML: canvas2D with 2 buttons
Forum Update on Monday, May 27th 2025

Controlling QML: canvas2D with 2 buttons

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 369 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aks17
    wrote on last edited by
    #1

    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.

    matthew.kuiashM J.HilkJ 2 Replies Last reply
    0
    • A aks17

      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.

      matthew.kuiashM Offline
      matthew.kuiashM Offline
      matthew.kuiash
      wrote on last edited by
      #2

      @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.

      The legendary cellist Pablo Casals was asked why he continued to practice at age 90. "Because I think I'm making progress," he replied.

      1 Reply Last reply
      0
      • A aks17

        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.

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        hi @aks17

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

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

        reset() removed all previous drawings.


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved