Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
6.5
-
None
Description
The following code results in the Switch's handle becoming black, when the expected behaviour is (also) a warning that NumberAnimation can only animate numbers.
Having this as a warning in qmllint would also be nice.
import QtQuick import QtQuick.Controls import QtQuick.Layouts ApplicationWindow { width: 800 height: 800 visible: true Switch { id: control y: 100 indicator: Rectangle { id: indicator x: control.leftPadding + (control.availableWidth - width) / 2 y: parent.height / 2 - height / 2 width: 52 height: 32 radius: height / 2 color: control.checked ? "pink" : "#444" Rectangle { id: handle x: Math.max(offset, Math.min(parent.width - offset - width, control.visualPosition * parent.width - (width / 2))) y: (parent.height - height) / 2 width: normalSize * largestScale height: normalSize * largestScale radius: width / 2 color: control.checked ? (control.hovered ? Qt.lighter("red") : "red") : (control.hovered ? Qt.lighter("grey") : "grey") scale: control.down ? 1 : (control.checked ? checkedSize / largestSize : normalSize / largestSize) readonly property int offset: 2 readonly property real normalSize: !hasIcon ? 16 : checkedSize readonly property real checkedSize: 24 readonly property real largestSize: 28 readonly property real largestScale: largestSize / normalSize readonly property bool hasIcon: control.icon.name.length > 0 || control.icon.source.toString().length > 0 Behavior on x { enabled: !control.pressed SmoothedAnimation { duration: 300 } } Behavior on scale { NumberAnimation { duration: 100 } } // Results in a black handle Behavior on color { NumberAnimation { duration: 200 } } } } } }