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

qmllint: duplicate-property-binding

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • 6.10
    • 6.10.0 Beta1
    • QML: Tooling
    • None
    • All

    Description

      Since Qt 6.10.0 Beta 1 we have the following warning

      Warning: App.qml:17:4: Duplicate binding on property 'size' [duplicate-property-binding]
      			SequentialAnimation on size {
      			^^^^^^^^^^^^^^^^^^^
      Warning: App.qml:15:24: Note: previous binding on 'size' here [duplicate-property-binding]
      			property real size: initialSize
                          			^^^^^^^^^^^
      

      Example:

      import QtQuick
      import QtQuick.Controls
      
      Window {
      	width: 640
      	height: 480
      	visible: true
      	title: qsTr("Hello World")
      
      	Column {
      		Item {
      			id: bindingTest
      
      			property real initialSize: 5
      			property real size: initialSize
      
      			SequentialAnimation on size {
      				id: animation
      
      				loops: Animation.Infinite
      				running: false
      
      				NumberAnimation {
      					duration: 5000
      					from: 0
      					to: bindingTest.initialSize
      				}
      				NumberAnimation {
      					duration: 5000
      					easing.type: Easing.Linear
      					from: bindingTest.initialSize
      					to: 0
      				}
      			}
      		}
      		Text {
      			text: bindingTest.size
      		}
      		Button {
      			text: "toggle"
      			onClicked: {
      				animation.running = !animation.running
      			}
      		}
      	}
      }
      

      Using

      property real size: 5
      

      leads to

      Warning: App.qml:17:4: Duplicate binding on property 'size' [duplicate-property-binding]
      			SequentialAnimation on size {
      			^^^^^^^^^^^^^^^^^^^
      Warning: App.qml:15:24: Note: previous binding on 'size' here [duplicate-property-binding]
      			property real size: 5
                          			^
      Warning: App.qml:17:4: Cannot combine value source and binding on property "size" [duplicate-property-binding]
      			SequentialAnimation on size {
      			^^^^^^^^^^^^^^^^^^^
      

      The workaround seems to be

      			property real size
      			Component.onCompleted: {
      				size = initialSize
      			}
      

      Our use case is to ensure the initial value even if the animation is not running.

      Attachments

        Issue Links

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

          Activity

            People

              fabiankosmale Fabian Kosmale
              larss Lars Schmertmann
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change