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

opacity property of Popup is overriden on visible changes with Material and FluentWinUI3 style

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4: Low
    • None
    • 6.8.0
    • Quick: Controls 2
    • None
    • Windows 11, PySide 6 (should be reproducible with C++/QML as well)
    • Windows

    Description

      The issue should be self-explanatory with the following simple program:

      import QtQuick
      import QtQuick.Window
      import QtQuick.Controls.FluentWinUI3
      
      ApplicationWindow {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Item {
              anchors.horizontalCenter: parent.horizontalCenter
              anchors.bottom: parent.bottom
              anchors.bottomMargin: 20
      
              implicitWidth: popup.width
              implicitHeight: popup.height
              Popup {
                  id: popup
                  anchors.centerIn: parent
                  closePolicy: Popup.NoAutoClose
                  opacity: 0.2
      
                  Label {
                      id: popupText
                      anchors.centerIn: parent
                      property string data
                      text: "Hi! " + data
      
                      horizontalAlignment: Text.AlignHCenter
                      verticalAlignment: Text.AlignVCenter
                  }
              }
          }
      
          SequentialAnimation {
              id: displayPopupAndFadeAway
              PropertyAction {
                  target: popup
                  property: "visible"
                  value: true
              }
              PropertyAction {
                  target: popup
                  property: "opacity"
                  value: 1.0
              }
              PauseAnimation {
                  duration: 3000
              }
              NumberAnimation {
                  target: popup
                  property: "opacity"
                  from: 1.0
                  to: 0.0
                  duration: 2000
              }
              PropertyAction {
                  target: popup
                  property: "visible"
                  value: false
              }
              PropertyAction {
                  target: popup
                  property: "opacity"
                  value: 1.0
              }
          }
      
          SequentialAnimation {
              id: justDisplayPopupAndDisappear
              PropertyAction {
                  target: popup
                  property: "visible"
                  value: true
              }
              PauseAnimation {
                  duration: 3000
              }
              PropertyAction {
                  target: popup
                  property: "visible"
                  value: false
              }
          }
      
          Column {
              anchors.centerIn: parent
              spacing: 5
              TextField {
                  id: textField
                  width: 200
                  height: 40
                  placeholderText: "Enter text"
                  onAccepted: {
                      popupText.data = textField.text;
                      displayPopupAndFadeAway.restart();
                  }
              }
              Button {
                  text: "Popup and disappear"
                  onClicked: {
                      popupText.data = textField.text;
                      justDisplayPopupAndDisappear.restart();
                  }
              }
              Button {
                  text: "Popup and fade away"
                  onClicked: {
                      popupText.data = textField.text;
                      displayPopupAndFadeAway.restart();
                  }
              }
              Label {
                  // use popup.opacity * 100 (cast to int)
                  text: "Current opacity of popup: " + Math.round(popup.opacity * 100) + "%"
              }
          }
      }
      
      

      Popup uses its own fade animation when visible property changes which overrides the publicly accessible opacity property. This conflicts with custom animation handling, such as the one shown in this example program. The internal fade animation should act on its own internal item instead of changing the publicly accessible opacity property.

      Windows style doesn't have this issue, but that's because it doesn't have a builtin fade animation at all.

      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
              jclink Jessia Clinkscale
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes