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

Layer effects do not work on QQuickWindow::contentItem

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.7.0
    • None

    Description

      Nothing is drawn when a layer effect is applied on the root item. A minimal dummy example:

      import QtQuick 2.7
      import QtQuick.Window 2.2
      
      Window {
          id: window
          width: 360
          height: 360
          visible: true
          title: "contentItem"
      
          contentItem.layer.enabled: true
          contentItem.layer.effect: ShaderEffect { }
      
          Text {
              text: "Content"
              font.pixelSize: 72
              anchors.centerIn: parent
          }
      }
      

      An example use case is to blur or desaturate the content (in a task switcher) when the application is not active. It works as long as the item is any other item than the root item:

      import QtQuick 2.7
      import QtQuick.Window 2.2
      import QtGraphicalEffects 1.0
      
      Window {
          id: window
          width: 360
          height: 360
          visible: true
          title: "otherItem"
      
          Item {
              id: otherItem
              anchors.fill: parent
      
              layer.enabled: !window.active
              layer.effect: FastBlur {
                  source: otherItem
                  radius: 32
              }
      
              Text {
                  color: "green"
                  text: "Other"
                  font.pixelSize: 72
                  anchors.centerIn: parent
              }
          }
      }
      

      Applying a layer effect on ApplicationWindow::contentItem does not apply to Qt Quick Controls 2 popups, which are re-parented to ApplicationWindow::overlay to ensure that they always appear on top of the content. The structure is:

      Window::contentItem
      ├─ ApplicationWindow::contentItem
      └─ ApplicationWindow::overlay
      

      Therefore being able to apply a layer effect on Window::contentItem would be nice.

      Attachments

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              jpnurmi J-P Nurmi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes