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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.0.1, 6.1.0 RC
    • Quick: Controls 2
    • Windows 10 64-bit, using Qt 6.0.1, MSVC2019 64-bit and QtCreator 4.14.2 (Built on Mar 19 2021 09:03:03 From revision c34b950227)
    • Windows

    Description

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

      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

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

        Activity

          People

            smd Jan Arve
            mikewheelmakersson Radu-Mihai Rotariu
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes