Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-42737

QML. Canvas is painted despite being invisible

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.3.2
    • Mac OS X Yosemite (10.10)

      In the example below, you'll get log output whenever window area is clicked. That proves that onPaint handler is called even when Canvas is invisible. Expectation is that it is not.

      import QtQuick 2.0
      
      Rectangle {
          width: 800
          height: 600
          color: "seagreen"
      
          Canvas {
              id: canvas
              anchors.fill: parent
              visible: false
              onPaint: {
                  console.log("visible:", visible)
                  console.trace()
                  var context = getContext("2d")
                  context.save()
                  context.fillStyle = "salmon"
                  context.fillRect(0, 0, width, height)
                  context.restore()
              }
          }
      
          MouseArea {
              anchors.fill: parent
              onPressed: canvas.requestPaint()
          }
      }
      

      The same is true in case canvas.markDirty(Qt.rect(0, 0, canvas.width, canvas.height)) is used.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            aalpert Alan Alpert
            dvolosnykh Dmitry Volosnykh
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes