From 6eb35df60e061b9ce4e88f97a174216e2b1c617f Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Mon, 23 Nov 2020 14:08:37 +0100 Subject: QML engine: Deprecate DefaultMethod Assigning objects to signal handlers can be convenient, as seen in the examples which use it together with ListView.onRemove. However, that convenience makes it hard to reason about what actually happens. Moreover, the only user of that functionality are the Animation classes, and the usage of DefaultMethod is not documented anywhere. [ChangeLog][QtQml] Assigning an object to a signal handler is deprecated. Instead, create the object, give it an id, and call the desired slot from the signal handler. For instance, instead of of ListView.onRemove: SequentialAnimation {...} use SequentialAnimation {id: removeAnimation; ...} ListView.onRemove: removeAnimation.start() A warning will be printed whenever an assignment of an object to a signal handler occurs. The warning can be controlled via the qt.qml.defaultmethod logging category. Change-Id: I001ddf4d7933871977f84a5e012d020fb043cc64 Reviewed-by: Ulf Hermann --- src/quick/doc/snippets/qml/listview/listview.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/quick/doc') diff --git a/src/quick/doc/snippets/qml/listview/listview.qml b/src/quick/doc/snippets/qml/listview/listview.qml index 759344b574..b7b4b508c3 100644 --- a/src/quick/doc/snippets/qml/listview/listview.qml +++ b/src/quick/doc/snippets/qml/listview/listview.qml @@ -94,11 +94,13 @@ Rectangle { Component { id: delegate Item { - ListView.onRemove: SequentialAnimation { + SequentialAnimation { + id: removeAnimation PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad } PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } } + ListView.onRemove: removeAnimation.start() } } //![delayRemove] -- cgit v1.2.3