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

Quick controls Popup - shadow is rendered incorrectly

    XMLWordPrintable

Details

    • macOS, Windows
    • ee975a136 (dev), 0666759d4 (6.7), 4bffe40db (tqtc/lts-6.5)

    Description

      Preconditions:
      QML Popup control, background has MultiEffect with shadow.
      There's a typical case when content is set by Loader, depending on some conditions, and Loader is not active until Popup is required (either "active: false" or "sourceComponent: null"). In such cases MultiEffect on background behaves very wrong. Please see attached screenshot and sample code.

      Probably it may also reproduce when content changes size while popup is already opened.

      Sample code:

      import QtQuick
      import QtQuick.Controls
      import QtQuick.Effects
      
      Window {
          width: 640
          height: 480
          visible: true
          color: "white"
      
          component Shadow : MultiEffect {
              shadowEnabled: true
              shadowColor: "black"
              shadowOpacity: 0.5
              shadowHorizontalOffset: 4
              shadowVerticalOffset: 5
          }
      
          component PopupFixedLayerEffect : Popup {
              id: control1
      
              background: Rectangle {
                  radius: 10
                  color: "white"
      
                  layer.enabled: true
                  layer.effect: Shadow {}
              }
          }
      
          component PopupDynamicLayerEffect : Popup {
              id: control2
      
              background: Rectangle {
                  radius: 10
                  color: "white"
      
                  layer.enabled: control2.visible
                  layer.effect: Shadow {}
              }
          }
      
          Rectangle { // Just for reference, how the shadow should look
              x: 20
              y: 20
              width: 200
              height: 200
              radius: 10
      
              layer.enabled: true
              layer.effect: Shadow {}
          }
      
          PopupFixedLayerEffect {
              id: p1;
              anchors.centerIn: parent
      
              Loader {
                  active: p1.visible
                  sourceComponent: Item {
                      width: 200
                      height: 200
                  }
              }
          }
          PopupFixedLayerEffect {
              id: p2;
              anchors.centerIn: parent
              Loader {
                  sourceComponent: Item {
                      width: 200
                      height: 200
                  }
              }
          }
          PopupDynamicLayerEffect {
              id: p3
              anchors.centerIn: parent
              Loader {
                  active: p3.visible
                  sourceComponent: Item {
                      width: 200
                      height: 200
                  }
              }
          }
      
          Column {
              spacing: 10
              anchors {
                  right: parent.right
                  top: parent.top
                  rightMargin: 20
                  topMargin: 20
              }
      
              Button {
                  text: "Fixed layer.enabled, dynamic content"
                  onClicked: p1.open()
              }
              Button {
                  text: "Fixed layer.enabled, fixed content"
                  onClicked: p2.open()
              }
              Button {
                  text: "Dynamic layer.enabled,  dynamic content"
                  onClicked: p3.open()
              }
          }
      }
      

      The differences are in layer.enabled binding of different popups' backgrounds and in active binding of content Loaders

      Attachments

        For Gerrit Dashboard: QTBUG-122746
        # Subject Branch Project Status CR V

        Activity

          People

            kagro Kaj Grönholm
            sergei.nevdakh Sergei Nevdakh
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes