diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-02-12 08:53:00 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-02-12 16:18:28 +0000 |
commit | 8784a2778063cf928b27a908f6580ed37cb4035d (patch) | |
tree | 5a0871bc6fdd795d7971bc43c3811ee467d4ff38 /src/qml | |
parent | 0e92e0bd6e7209ad491472b3928840ad78c5371a (diff) |
Use functions as signal handlers when accessing parameters
Injected signal handlers are bad practice because they aren't declared.
Task-number: QTBUG-89943
Change-Id: I3a691f68342a199bd63034637aa7ed438e3a037b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 4cc91a6a0e4f9063233a4d6554ae64855cf99c14)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/qml')
6 files changed, 11 insertions, 11 deletions
diff --git a/src/qml/doc/snippets/qml/events.qml b/src/qml/doc/snippets/qml/events.qml index f437e32890..d29be5ebd2 100644 --- a/src/qml/doc/snippets/qml/events.qml +++ b/src/qml/doc/snippets/qml/events.qml @@ -66,7 +66,7 @@ Rectangle { //! [signal handler declaration] onTrigger: console.log("trigger signal emitted") -onSend: { +onSend: (notice)=> { console.log("send signal emitted with notice: " + notice) } @@ -90,7 +90,7 @@ Rectangle { signal send(person: string, notice: string) - onSend: { + onSend: (person, notice)=> { console.log("For " + person + ", the notice is: " + notice) } @@ -103,7 +103,7 @@ Rectangle { id: relay signal send(person: string, notice: string) - onSend: console.log("Send signal to: " + person + ", " + notice) + onSend: (person, notice)=> console.log("Send signal to: " + person + ", " + notice) Component.onCompleted: { relay.send.connect(sendToPost) diff --git a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc index 5c53989cbb..618ed1e334 100644 --- a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc +++ b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc @@ -498,7 +498,7 @@ value: \qml MessageBoard { - onNewMessagePosted: console.log("New message received:", subject) + onNewMessagePosted: (subject)=> console.log("New message received:", subject) } \endqml diff --git a/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc b/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc index a4119ff793..718b0c25ac 100644 --- a/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc +++ b/src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc @@ -208,7 +208,7 @@ Rectangle { MouseArea { id: mouseArea anchors.fill: parent - onClicked: root.buttonClicked(mouse.x, mouse.y) + onClicked: (mouse)=> root.buttonClicked(mouse.x, mouse.y) } } \endqml @@ -224,7 +224,7 @@ import QtQuick 2.0 SquareButton { id: squareButton - onButtonClicked: { + onButtonClicked: (xPos, yPos)=> { console.log("Clicked", xPos, yPos) randomizeColor() } diff --git a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc index ecfef2e04f..787e7b920b 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc @@ -852,8 +852,8 @@ Rectangle { MouseArea { anchors.fill: parent - onPressed: root.activated(mouse.x, mouse.y) onReleased: root.deactivated() + onPressed: (mouse)=> root.activated(mouse.x, mouse.y) } } \endqml @@ -865,8 +865,8 @@ provided by the client: \qml // myapplication.qml SquareButton { - onActivated: console.log("Activated at " + xPosition + "," + yPosition) onDeactivated: console.log("Deactivated!") + onActivated: (xPosition, yPosition)=> console.log("Activated at " + xPosition + "," + yPosition) } \endqml @@ -954,7 +954,7 @@ Item { MouseArea { anchors.fill: parent - onClicked: label.moveTo(mouse.x, mouse.y) + onClicked: (mouse)=> label.moveTo(mouse.x, mouse.y) } Text { diff --git a/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc b/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc index dd71347b2a..1c13636689 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc @@ -220,7 +220,7 @@ Now any objects of the \c SquareButton can connect to the \c activated signal us \qml // myapplication.qml SquareButton { - onActivated: console.log("Activated at " + xPosition + "," + yPosition) + onActivated: (xPosition, yPosition)=> console.log("Activated at " + xPosition + "," + yPosition) } \endqml diff --git a/src/qml/types/qqmlconnections.cpp b/src/qml/types/qqmlconnections.cpp index 676c15e01f..7767909169 100644 --- a/src/qml/types/qqmlconnections.cpp +++ b/src/qml/types/qqmlconnections.cpp @@ -88,7 +88,7 @@ public: \qml MouseArea { - onClicked: { foo(parameters) } + onClicked: (mouse)=> { foo(mouse) } } \endqml |