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. Do the Canvas has contextReady event?

Do the Canvas has contextReady event?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 407 Views 1 Watching
  • 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.
  • CKurduC Offline
    CKurduC Offline
    CKurdu
    wrote on last edited by CKurdu
    #1

    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: {
                GSystem.initAnim(a,b);
                GSystem.drawAnim();
            }
            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?

    You reap what you sow it

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      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
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      CKurduC 1 Reply Last reply
      1
      • dheerendraD dheerendra

        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")
                        }
                    }
        
        CKurduC Offline
        CKurduC Offline
        CKurdu
        wrote on last edited by
        #3

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

        You reap what you sow it

        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