diff options
Diffstat (limited to 'src/quick')
20 files changed, 33 insertions, 31 deletions
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 |