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

QtQuick.Controls Button.qml wrong parent used for transitionDuration (line 77)

    XMLWordPrintable

Details

    • Windows
    • e548d825aef388178147f27539b17cc8dc0d5e9a (qt/qtquickcontrols2/dev) a823571e47d536367423d3c3e0a90e4f885bcf46 (qt/qtquickcontrols2/6.2) 57b4958888696fed6049665b1d7043719c04121a (qt/qtquickcontrols2/6.1)

    Description

      file:///C:/Qt/6.0.1/msvc2019_64/qml/QtQuick/Controls/Windows/Button.qml:77:49: Unable to assign [undefined] to int.

      file:///C:/Qt/6.1.1/msvc2019_64/qml/QtQuick/Controls/Windows/Button.qml:77:49: Unable to assign [undefined] to int

      Steps to reproduce the problem:

      1. run the attached project
      2. hover mouse cursor on top of the button

      This warning comes up because in Button.qml at line 77 duration is set from the parent's transitionDuration, but the parent does not have one.

      The warning is raised at runtime and happens if you hover over a button which does not set the transitionDuration manually before instantiating the object.

      The parent at line 77 is Behaviour, but the intended parent is the Button in which the Behaviour is defined.

      It should be either parent.parent.transitionDuration or an id can be set for the NativeStyle.Button which is used to guide to the intended parent and use that like so:

          NativeStyle.Button {
              id: exampleName
              control: control
              x: background.x
              y: background.y
              width: background.width
              height: background.height
              useNinePatchImage: false
              overrideState: NativeStyle.StyleItem.AlwaysHovered
              opacity: control.hovered ? 1 : 0
      
              Behavior on opacity {
                  NumberAnimation { duration: exampleName.transitionDuration }
              }
          }
      

      Attachments

        1. qtbug92824.zip
          1 kB
          Miika Pernu
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mitch_curtis Mitch Curtis
            mikewheelmakersson Radu-Mihai Rotariu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes