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

QML. Canvas is painted despite being invisible

    XMLWordPrintable

Details

    Description

      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.

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes