summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-02-12 08:53:00 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-02-12 10:30:20 +0000
commit4cc91a6a0e4f9063233a4d6554ae64855cf99c14 (patch)
tree89175c0d09b16926a95c3b1239f73971beacf5bb
parenteaa9993682f02ef0420ec49b816da27db3ca00c2 (diff)
Use functions as signal handlers when accessing parameters
Injected signal handlers are bad practice because they aren't declared. Pick-to: 6.1 Task-number: QTBUG-89943 Change-Id: I3a691f68342a199bd63034637aa7ed438e3a037b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--examples/qml/dynamicscene/content/PaletteItem.qml6
-rw-r--r--examples/quick/particles/system/content/dynamicemitters.qml2
-rw-r--r--examples/quick/particles/system/content/startstop.qml2
-rw-r--r--examples/quick/particles/system/content/timedgroupchanges.qml2
-rw-r--r--examples/quick/shapes/content/interactive.qml6
-rw-r--r--examples/quick/touchinteraction/pincharea/flickresize.qml2
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml2
-rw-r--r--examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame3/samegame.qml2
-rw-r--r--examples/quick/tutorials/samegame/samegame4/samegame.qml3
-rw-r--r--src/qml/doc/snippets/qml/events.qml6
-rw-r--r--src/qml/doc/src/cppintegration/exposecppattributes.qdoc2
-rw-r--r--src/qml/doc/src/qmllanguageref/documents/definetypes.qdoc4
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc6
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/signals.qdoc2
-rw-r--r--src/qml/types/qqmlconnections.cpp2
-rw-r--r--src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml4
-rw-r--r--src/quick/doc/snippets/pointerHandlers/tapHandlerOnTapped.qml6
-rw-r--r--src/quick/doc/snippets/pointerHandlers/wheelHandler.qml5
-rw-r--r--src/quick/doc/snippets/qml/focus/MyClickableWidget.qml2
-rw-r--r--src/quick/doc/snippets/qml/focus/MyWidget.qml2
-rw-r--r--src/quick/doc/snippets/qml/focus/basicwidget.qml2
-rw-r--r--src/quick/doc/snippets/qml/focus/myfocusscopewidget.qml2
-rw-r--r--src/quick/doc/snippets/qml/focus/rectangle.qml2
-rw-r--r--src/quick/doc/snippets/qml/keys/keys-pressed.qml2
-rw-r--r--src/quick/doc/snippets/qml/loader/KeyReader.qml2
-rw-r--r--src/quick/doc/snippets/qml/loader/connections.qml2
-rw-r--r--src/quick/doc/snippets/qml/loader/focus.qml2
-rw-r--r--src/quick/doc/snippets/qml/mousearea/mousearea.qml2
-rw-r--r--src/quick/doc/snippets/qml/qml-extending-types/signals/Button.qml2
-rw-r--r--src/quick/doc/snippets/qml/qml-extending-types/signals/parameters.qml2
-rw-r--r--src/quick/doc/snippets/qml/springanimation.qml2
-rw-r--r--src/quick/doc/snippets/qml/text/onLinkActivated.qml2
-rw-r--r--src/quick/items/qquickevents.cpp15
-rw-r--r--src/quick/items/qquickitem.cpp4
-rw-r--r--src/quick/items/qquickmousearea.cpp2
-rw-r--r--src/quick/items/qquicktext.cpp4
-rw-r--r--tools/qmltime/linelaidout.qml2
38 files changed, 62 insertions, 59 deletions
diff --git a/examples/qml/dynamicscene/content/PaletteItem.qml b/examples/qml/dynamicscene/content/PaletteItem.qml
index 72c4e6a27f..ca734a5dba 100644
--- a/examples/qml/dynamicscene/content/PaletteItem.qml
+++ b/examples/qml/dynamicscene/content/PaletteItem.qml
@@ -62,8 +62,8 @@ Image {
MouseArea {
anchors.fill: parent
- onPressed: Code.startDrag(mouse);
- onPositionChanged: Code.continueDrag(mouse);
- onReleased: Code.endDrag(mouse);
+ onPressed: (mouse)=> Code.startDrag(mouse);
+ onPositionChanged: (mouse)=> Code.continueDrag(mouse);
+ onReleased: (mouse)=> Code.endDrag(mouse);
}
}
diff --git a/examples/quick/particles/system/content/dynamicemitters.qml b/examples/quick/particles/system/content/dynamicemitters.qml
index 226e6de870..8eb87d2baa 100644
--- a/examples/quick/particles/system/content/dynamicemitters.qml
+++ b/examples/quick/particles/system/content/dynamicemitters.qml
@@ -138,7 +138,7 @@ Rectangle {
}
MouseArea {
anchors.fill: parent
- onClicked: customEmit(mouse.x, mouse.y);
+ onClicked: (mouse)=> customEmit(mouse.x, mouse.y);
}
Text {
diff --git a/examples/quick/particles/system/content/startstop.qml b/examples/quick/particles/system/content/startstop.qml
index cf9ad3d79d..a9ef7285aa 100644
--- a/examples/quick/particles/system/content/startstop.qml
+++ b/examples/quick/particles/system/content/startstop.qml
@@ -63,7 +63,7 @@ Rectangle {
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
- onClicked: {
+ onClicked: (mouse) => {
if (mouse.button == Qt.LeftButton)
particles.running = !particles.running
else
diff --git a/examples/quick/particles/system/content/timedgroupchanges.qml b/examples/quick/particles/system/content/timedgroupchanges.qml
index 9865d3294e..cab992f898 100644
--- a/examples/quick/particles/system/content/timedgroupchanges.qml
+++ b/examples/quick/particles/system/content/timedgroupchanges.qml
@@ -88,7 +88,7 @@ Rectangle {
duration: 1000
Affector {
once: true
- onAffected: worksEmitter.burst(400,x,y)
+ onAffected: (x, y)=> worksEmitter.burst(400,x,y)
}
}
//! [2]
diff --git a/examples/quick/shapes/content/interactive.qml b/examples/quick/shapes/content/interactive.qml
index 78413db3f9..1f7aad3ab0 100644
--- a/examples/quick/shapes/content/interactive.qml
+++ b/examples/quick/shapes/content/interactive.qml
@@ -190,7 +190,7 @@ Rectangle {
onExited: color = rr.color
onPressed: a = true
onReleased: a = false
- onPositionChanged: {
+ onPositionChanged: (mouse)=> {
if (a) {
var pt = mapToItem(rr.parent, mouse.x, mouse.y);
rr.obj[rr.xprop] = pt.x
@@ -323,10 +323,10 @@ Rectangle {
MouseArea {
anchors.fill: parent
- onPressed: {
+ onPressed: (mouse)=> {
canvas.funcs[root.mode].start(mouse.x, mouse.y);
}
- onPositionChanged: {
+ onPositionChanged: (mouse)=> {
canvas.funcs[root.mode].move(mouse.x, mouse.y);
}
onReleased: {
diff --git a/examples/quick/touchinteraction/pincharea/flickresize.qml b/examples/quick/touchinteraction/pincharea/flickresize.qml
index 65db04693d..994fd01b50 100644
--- a/examples/quick/touchinteraction/pincharea/flickresize.qml
+++ b/examples/quick/touchinteraction/pincharea/flickresize.qml
@@ -73,7 +73,7 @@ Rectangle {
initialHeight = flick.contentHeight
}
- onPinchUpdated: {
+ onPinchUpdated: (pinch)=> {
// adjust content pos due to drag
flick.contentX += pinch.previousCenter.x - pinch.center.x
flick.contentY += pinch.previousCenter.y - pinch.center.y
diff --git a/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml
index 6c64ee2893..eb42a76a47 100644
--- a/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml
+++ b/examples/quick/tutorials/dynamicview/dynamicview3/dynamicview.qml
@@ -120,7 +120,7 @@ Rectangle {
DropArea {
anchors { fill: parent; margins: 10 }
- onEntered: {
+ onEntered: (drag)=> {
visualModel.items.move(
drag.source.DelegateModel.itemsIndex,
dragArea.DelegateModel.itemsIndex)
diff --git a/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml
index 327ca0cea7..f40f060e7c 100644
--- a/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml
+++ b/examples/quick/tutorials/dynamicview/dynamicview4/dynamicview.qml
@@ -121,7 +121,7 @@ Rectangle {
DropArea {
anchors { fill: parent; margins: 10 }
- onEntered: {
+ onEntered: (drag)=> {
visualModel.items.move(
drag.source.DelegateModel.itemsIndex,
dragArea.DelegateModel.itemsIndex)
diff --git a/examples/quick/tutorials/samegame/samegame3/samegame.qml b/examples/quick/tutorials/samegame/samegame3/samegame.qml
index a84cc67146..11376232a2 100644
--- a/examples/quick/tutorials/samegame/samegame3/samegame.qml
+++ b/examples/quick/tutorials/samegame/samegame3/samegame.qml
@@ -83,7 +83,7 @@ Rectangle {
MouseArea {
anchors.fill: parent
- onClicked: SameGame.handleClick(mouse.x, mouse.y)
+ onClicked: (mouse)=> SameGame.handleClick(mouse.x, mouse.y)
}
}
//![1]
diff --git a/examples/quick/tutorials/samegame/samegame4/samegame.qml b/examples/quick/tutorials/samegame/samegame4/samegame.qml
index 2bfdca9bd6..0cdbcd8cb0 100644
--- a/examples/quick/tutorials/samegame/samegame4/samegame.qml
+++ b/examples/quick/tutorials/samegame/samegame4/samegame.qml
@@ -80,7 +80,8 @@ Rectangle {
height: parent.height - (parent.height % blockSize);
MouseArea {
- anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y);
+ anchors.fill: parent
+ onClicked: (mouse)=> SameGame.handleClick(mouse.x,mouse.y);
}
}
}
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
diff --git a/src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml b/src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml
index cc637d34cf..cc4d941ff6 100644
--- a/src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml
+++ b/src/qmlworkerscript/doc/snippets/qml/workerscript/workerscript.qml
@@ -63,12 +63,12 @@ Rectangle {
id: myWorker
source: "script.mjs"
- onMessage: myText.text = messageObject.reply
+ onMessage: (messageObject)=> myText.text = messageObject.reply
}
MouseArea {
anchors.fill: parent
- onClicked: myWorker.sendMessage({ 'x': mouse.x, 'y': mouse.y })
+ onClicked: (mouse)=> myWorker.sendMessage({ 'x': mouse.x, 'y': mouse.y })
}
}
//![0]
diff --git a/src/quick/doc/snippets/pointerHandlers/tapHandlerOnTapped.qml b/src/quick/doc/snippets/pointerHandlers/tapHandlerOnTapped.qml
index f556c238da..deff59d034 100644
--- a/src/quick/doc/snippets/pointerHandlers/tapHandlerOnTapped.qml
+++ b/src/quick/doc/snippets/pointerHandlers/tapHandlerOnTapped.qml
@@ -56,9 +56,9 @@ Rectangle {
TapHandler {
acceptedButtons: Qt.LeftButton | Qt.RightButton
- onTapped: console.log("tapped", eventPoint.event.device.name,
- "button", eventPoint.event.button,
- "@", eventPoint.scenePosition)
+ onTapped: (eventPoint)=> console.log("tapped", eventPoint.event.device.name,
+ "button", eventPoint.event.button,
+ "@", eventPoint.scenePosition)
}
}
//![0]
diff --git a/src/quick/doc/snippets/pointerHandlers/wheelHandler.qml b/src/quick/doc/snippets/pointerHandlers/wheelHandler.qml
index 2c9913ac97..b3d659b4e5 100644
--- a/src/quick/doc/snippets/pointerHandlers/wheelHandler.qml
+++ b/src/quick/doc/snippets/pointerHandlers/wheelHandler.qml
@@ -56,8 +56,9 @@ Rectangle {
WheelHandler {
property: "rotation"
- onWheel: console.log("rotation", event.angleDelta.y,
- "scaled", rotation, "@", point.position, "=>", parent.rotation)
+ onWheel: (event)=> console.log("rotation", event.angleDelta.y,
+ "scaled", rotation, "@", point.position,
+ "=>", parent.rotation)
}
}
//![0]
diff --git a/src/quick/doc/snippets/qml/focus/MyClickableWidget.qml b/src/quick/doc/snippets/qml/focus/MyClickableWidget.qml
index a5a4eae0ab..43d5defad4 100644
--- a/src/quick/doc/snippets/qml/focus/MyClickableWidget.qml
+++ b/src/quick/doc/snippets/qml/focus/MyClickableWidget.qml
@@ -65,7 +65,7 @@ FocusScope {
color: "lightsteelblue"; width: 175; height: 25; radius: 10; antialiasing: true
Text { id: label; anchors.centerIn: parent }
focus: true
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
if (event.key == Qt.Key_A)
label.text = 'Key A was pressed'
else if (event.key == Qt.Key_B)
diff --git a/src/quick/doc/snippets/qml/focus/MyWidget.qml b/src/quick/doc/snippets/qml/focus/MyWidget.qml
index 82d7ee35b4..d446489813 100644
--- a/src/quick/doc/snippets/qml/focus/MyWidget.qml
+++ b/src/quick/doc/snippets/qml/focus/MyWidget.qml
@@ -56,7 +56,7 @@ Rectangle {
color: "lightsteelblue"; width: 175; height: 25; radius: 10; antialiasing: true
Text { id: label; anchors.centerIn: parent}
focus: true
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
if (event.key == Qt.Key_A)
label.text = 'Key A was pressed'
else if (event.key == Qt.Key_B)
diff --git a/src/quick/doc/snippets/qml/focus/basicwidget.qml b/src/quick/doc/snippets/qml/focus/basicwidget.qml
index ddcf95b69a..3fd9fab748 100644
--- a/src/quick/doc/snippets/qml/focus/basicwidget.qml
+++ b/src/quick/doc/snippets/qml/focus/basicwidget.qml
@@ -56,7 +56,7 @@ Rectangle {
Item {
id: keyHandler
focus: true
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
if (event.key == Qt.Key_A)
myText.text = 'Key A was pressed'
else if (event.key == Qt.Key_B)
diff --git a/src/quick/doc/snippets/qml/focus/myfocusscopewidget.qml b/src/quick/doc/snippets/qml/focus/myfocusscopewidget.qml
index 3283bcfcbf..6dd892f37d 100644
--- a/src/quick/doc/snippets/qml/focus/myfocusscopewidget.qml
+++ b/src/quick/doc/snippets/qml/focus/myfocusscopewidget.qml
@@ -64,7 +64,7 @@ FocusScope {
color: "lightsteelblue"; width: 175; height: 25; radius: 10; antialiasing: true
Text { id: label; anchors.centerIn: parent }
focus: true
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
if (event.key == Qt.Key_A)
label.text = 'Key A was pressed'
else if (event.key == Qt.Key_B)
diff --git a/src/quick/doc/snippets/qml/focus/rectangle.qml b/src/quick/doc/snippets/qml/focus/rectangle.qml
index 5675ae44b2..d49bf1d0d6 100644
--- a/src/quick/doc/snippets/qml/focus/rectangle.qml
+++ b/src/quick/doc/snippets/qml/focus/rectangle.qml
@@ -53,7 +53,7 @@ import QtQuick 2.0
Rectangle {
width: 100; height: 100
focus: true
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
if (event.key == Qt.Key_A) {
console.log('Key A was pressed');
event.accepted = true;
diff --git a/src/quick/doc/snippets/qml/keys/keys-pressed.qml b/src/quick/doc/snippets/qml/keys/keys-pressed.qml
index 418691dc9a..592d83b525 100644
--- a/src/quick/doc/snippets/qml/keys/keys-pressed.qml
+++ b/src/quick/doc/snippets/qml/keys/keys-pressed.qml
@@ -57,7 +57,7 @@ Item {
Item {
anchors.fill: parent
focus: true
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
if (event.key == Qt.Key_Left) {
console.log("move left");
event.accepted = true;
diff --git a/src/quick/doc/snippets/qml/loader/KeyReader.qml b/src/quick/doc/snippets/qml/loader/KeyReader.qml
index 56604319e0..c68ebf4f1a 100644
--- a/src/quick/doc/snippets/qml/loader/KeyReader.qml
+++ b/src/quick/doc/snippets/qml/loader/KeyReader.qml
@@ -42,7 +42,7 @@ import QtQuick 2.0
Item {
Item {
focus: true
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
console.log("KeyReader captured:",
event.text);
event.accepted = true;
diff --git a/src/quick/doc/snippets/qml/loader/connections.qml b/src/quick/doc/snippets/qml/loader/connections.qml
index 5ff57a1d38..5b2126a8fd 100644
--- a/src/quick/doc/snippets/qml/loader/connections.qml
+++ b/src/quick/doc/snippets/qml/loader/connections.qml
@@ -49,7 +49,7 @@ Item {
Connections {
target: myLoader.item
- onMessage: console.log(msg)
+ function onMessage(msg) { console.log(msg) }
}
}
//![0]
diff --git a/src/quick/doc/snippets/qml/loader/focus.qml b/src/quick/doc/snippets/qml/loader/focus.qml
index f3509021f1..b59f72c729 100644
--- a/src/quick/doc/snippets/qml/loader/focus.qml
+++ b/src/quick/doc/snippets/qml/loader/focus.qml
@@ -54,7 +54,7 @@ Rectangle {
}
}
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
console.log("Captured:",
event.text);
}
diff --git a/src/quick/doc/snippets/qml/mousearea/mousearea.qml b/src/quick/doc/snippets/qml/mousearea/mousearea.qml
index fd47752bb7..d3f307c0f2 100644
--- a/src/quick/doc/snippets/qml/mousearea/mousearea.qml
+++ b/src/quick/doc/snippets/qml/mousearea/mousearea.qml
@@ -77,7 +77,7 @@ Rectangle {
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
- onClicked: {
+ onClicked: (mouse)=> {
if (mouse.button == Qt.RightButton)
parent.color = 'blue';
else
diff --git a/src/quick/doc/snippets/qml/qml-extending-types/signals/Button.qml b/src/quick/doc/snippets/qml/qml-extending-types/signals/Button.qml
index 96f7fc1c7c..709582986d 100644
--- a/src/quick/doc/snippets/qml/qml-extending-types/signals/Button.qml
+++ b/src/quick/doc/snippets/qml/qml-extending-types/signals/Button.qml
@@ -59,7 +59,7 @@ Rectangle {
MouseArea {
anchors.fill: parent
- onClicked: rect.buttonClicked(mouse.x, mouse.y)
+ onClicked: (mouse)=> rect.buttonClicked(mouse.x, mouse.y)
}
}
//![0]
diff --git a/src/quick/doc/snippets/qml/qml-extending-types/signals/parameters.qml b/src/quick/doc/snippets/qml/qml-extending-types/signals/parameters.qml
index 8c9c5a09ab..2de2e9bbc7 100644
--- a/src/quick/doc/snippets/qml/qml-extending-types/signals/parameters.qml
+++ b/src/quick/doc/snippets/qml/qml-extending-types/signals/parameters.qml
@@ -52,7 +52,7 @@ import QtQuick 2.0
// application.qml
Button {
width: 100; height: 100
- onButtonClicked: {
+ onButtonClicked: (xPos, yPos)=> {
console.log("Mouse clicked at " + xPos + "," + yPos)
}
}
diff --git a/src/quick/doc/snippets/qml/springanimation.qml b/src/quick/doc/snippets/qml/springanimation.qml
index 658bcfb7d7..c18d662abc 100644
--- a/src/quick/doc/snippets/qml/springanimation.qml
+++ b/src/quick/doc/snippets/qml/springanimation.qml
@@ -65,7 +65,7 @@ Item {
MouseArea {
anchors.fill: parent
- onClicked: {
+ onClicked: (mouse)=> {
rect.x = mouse.x - rect.width/2
rect.y = mouse.y - rect.height/2
}
diff --git a/src/quick/doc/snippets/qml/text/onLinkActivated.qml b/src/quick/doc/snippets/qml/text/onLinkActivated.qml
index 07bae61089..b6c876f3d7 100644
--- a/src/quick/doc/snippets/qml/text/onLinkActivated.qml
+++ b/src/quick/doc/snippets/qml/text/onLinkActivated.qml
@@ -56,7 +56,7 @@ Rectangle {
Text {
textFormat: Text.RichText
text: "See the <a href=\"http://qt-project.org\">Qt Project website</a>."
- onLinkActivated: console.log(link + " link activated")
+ onLinkActivated: (link)=> console.log(link + " link activated")
}
//![0]
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 8df3c1b7dd..ba9082cc2a 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -65,7 +65,7 @@ Q_LOGGING_CATEGORY(lcPointerEvents, "qt.quick.pointer.events")
\qml
Item {
focus: true
- Keys.onPressed: { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; }
+ Keys.onPressed: (event)=> { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; }
}
\endqml
*/
@@ -148,7 +148,7 @@ Item {
\qml
Item {
focus: true
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
if ((event.key == Qt.Key_Enter) && (event.modifiers & Qt.ShiftModifier))
doSomething();
}
@@ -165,7 +165,7 @@ Item {
\qml
Item {
focus: true
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
if (event.matches(StandardKey.Undo))
myModel.undo();
else if (event.matches(StandardKey.Redo))
@@ -278,7 +278,7 @@ bool QQuickKeyEvent::matches(QKeySequence::StandardKey matchKey) const
For example, to react to a Shift key + Left mouse button click:
\qml
MouseArea {
- onClicked: {
+ onClicked: (mouse)=> {
if ((mouse.button == Qt.LeftButton) && (mouse.modifiers & Qt.ShiftModifier))
doSomething();
}
@@ -322,8 +322,9 @@ bool QQuickKeyEvent::matches(QKeySequence::StandardKey matchKey) const
For example, to react only to events which come from an actual mouse:
\qml
MouseArea {
- onPressed: if (mouse.source !== Qt.MouseEventNotSynthesized) {
- mouse.accepted = false
+ onPressed: (mouse)=> {
+ if (mouse.source !== Qt.MouseEventNotSynthesized)
+ mouse.accepted = false
}
onClicked: doSomething()
@@ -449,7 +450,7 @@ bool QQuickKeyEvent::matches(QKeySequence::StandardKey matchKey) const
For example, to react to a Control key pressed during the wheel event:
\qml
MouseArea {
- onWheel: {
+ onWheel: (wheel)=> {
if (wheel.modifiers & Qt.ControlModifier) {
adjustZoom(wheel.angleDelta.y / 120);
}
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 38e83e08ff..d9733309b1 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -968,7 +968,7 @@ bool QQuickKeysAttached::isConnected(const char *signalName) const
focus: true
// Ensure that we get escape key press events first.
- Keys.onShortcutOverride: event.accepted = (event.key === Qt.Key_Escape)
+ Keys.onShortcutOverride: (event)=> event.accepted = (event.key === Qt.Key_Escape)
Keys.onEscapePressed: {
console.log("escapeItem is handling escape");
@@ -1922,7 +1922,7 @@ void QQuickItemPrivate::updateSubFocusItem(QQuickItem *scope, bool focus)
Item {
focus: true
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
if (event.key == Qt.Key_Left) {
console.log("move left");
event.accepted = true;
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index 1a406dbbc2..ac7c23f7a2 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -597,7 +597,7 @@ void QQuickMouseArea::setPreventStealing(bool prevent)
MouseArea {
anchors.fill: parent
propagateComposedEvents: true
- onClicked: {
+ onClicked: (mouse)=> {
console.log("clicked blue")
mouse.accepted = false
}
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index de8c9d5297..9e56bd45e9 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -1412,7 +1412,7 @@ QQuickText::~QQuickText()
For example, this will move the first 5 lines of a Text item by 100 pixels to the right:
\code
- onLineLaidOut: {
+ onLineLaidOut: (line)=> {
if (line.number < 5) {
line.x = line.x + 100
line.width = line.width - 100
@@ -1422,7 +1422,7 @@ QQuickText::~QQuickText()
The following example will allow you to position an item at the end of the last line:
\code
- onLineLaidOut: {
+ onLineLaidOut: (line)=> {
if (line.isLast) {
lastLineMarker.x = line.x + line.implicitWidth
lastLineMarker.y = line.y + (line.height - lastLineMarker.height) / 2
diff --git a/tools/qmltime/linelaidout.qml b/tools/qmltime/linelaidout.qml
index 0e9da83087..e8ac636ed6 100644
--- a/tools/qmltime/linelaidout.qml
+++ b/tools/qmltime/linelaidout.qml
@@ -40,7 +40,7 @@ Item {
font.pixelSize: 15
font.bold: true
- onLineLaidOut: {
+ onLineLaidOut: (line)=> {
line.x = (line.number % 7) * 70
line.y = Math.floor(line.number / 7.0) * 70
}